Functions
Conditional

has(string, substring)
Check if a string contains the substring.
Parameters
string
The string to check
substring
The substring to search for
Return Value
Returns 1 if the substring is found within string, otherwise 0.
Discussion
The search is not case sensitive, so "vo2max" will match a title that contains "VO2MAX" or "VO2max" too. The
has
function is most often used as part of the condition part of theif
function.Athlete Level Examples
Gives TSS for all workouts that have vo2max in the title.

hastag(string)
Check if a workout has the specified tag.
Parameters
string
The tag to check.
Return Value
Returns 1 if the workout has the tag, otherwise 0.
Discussion
A workout can have zero or more tags. This function returns 1 if
string
is equal to one of the workout's tags. The search is not case sensitive, butstring
must match the entire tag. Thehastag
function is most often used as part of the condition part of theif
function. 
if(condition, truevalue)
Check a condition and give
truevalue
if the condition is true.Parameters
condition
The condition to check.
truevalue
The value to use if condition is true.
Return Value
Returns
truevalue
ifcondition
is true, otherwise returns .Discussion
This function allows you to include or exclude values from a set based on a condition, thus transforming or creating a subset of the data.
Workout Level Examples
if(cadence>0 and cadence<50, cadence)
Gives all cadence values that are greater than zero but less than 50.
Gives the average of all power values that exceed the sFTP for that workout.
Athlete Level Examples
Gives the workout date & time for all workouts that have maximum power over 1000W.
See Also

if(condition, truevalue, falsevalue)
Check a condition and give
truevalue
if the condition is true, orfalsevalue
if the condition is false.Parameters
condition
The condition to check.
truevalue
The value to use if condition is true.
falsevalue
The value to use if condition is false.
Return Value
For each value in
condition
, returnstruevalue
if is true, otherwise returnsfalsevalue
.Discussion
This function allows you to choose values from two different data sets depending on a condition.
Athlete Level Examples
if(date < today, tss, plannedtss)
Gives completed TSS values for workouts prior to today, but planned TSS values for workouts today or in the future.
See Also

isvalid(numbers)
For one or more numbers, returns one (true) if it is valid, or zero (false) if it is not a number (na).
Parameters
numbers
The numbers to check.
Return Value
Returns 1 if the number is a valid number, otherwise 0.
Discussion
In some cases a number is missing, which is different than zero. For example, if a bike workout doesn't have a power channel, then the average power is not zero, it is missing. Numbers that are missing are equal to the constant na which stands for not available or not a number.
Date

date(value)
Converts a weekvalue, monthvalue, or yearvalue to a date.
Parameters
value
A weekvalue, monthvalue, or yearvalue.
Return Value
A datevalue.
Discussion
If you convert a datevalue using a
weekvalue
,monthvalue
oryearvalue
function, you can convert it back to a datevalue. This can be useful if you want to do arithmetic on a weekvalue, monthvalue or yearvalue and convert back to a date.Examples
Gives the date of the first day of next week. You pick which day of week is first (Sunday, Monday, ...) using WKO4 Preferences.
date(trunc(monthval(today))+1)1
Gives the date of the last day of the current month.
Gives the first date of the current year.
date(trunc(yearval(today))+1)1
Gives the last date of the current year.

date(year, month, day)
Creates a date value using the month, day and year components.
Parameters
year
Four digit year number.
day
Day number starting with 1.
month
Month number between 1 and 12.
Return Value
A date value corresponding to the values year, month, day.
Discussion
When you enter a date value like 4/5/2016 into WKO4, the date is interpreted according to the current region settings on your computer, so that could mean April 5th or May 4th. The
date
function eliminates that ambiguity and is interpreted the same way regardless of region settings. Dates in WKO4 are stored internally as days since January 1, 1901. WKO4 displays a date using the computer's regional settings when using the units "date" otherwise it shows a fractional number.Examples
date(2016, 4, 7)
Gives the date April 7, 2016, but the formatting depends on the units selected. In North America WKO4 will show 4/7/2016 if the units are date. If the units are not date then it will show the number 42,100.
date(2015, month(today), day(today))
Gives the date in 2015 corresponding to today's month and day.
Gives the number of days since July 1, 2015.

day(datevalues)
Get the day of month for one or more dates.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the day of month (a number between 1 and 31) for
datevalues
.Examples
Gives the day of month for today.
Gives the day of month for yesterday, today, and tomorrow.
Athlete Level Examples
Gives the day of month for the workout date of all the workouts int the selected range.

dayofweek(date)
Gives the day of week as an offset to first day of the week according to the Preferences setting.
Parameters
date
One or more date values.
Return Value
A number between 0 and 6.
Discussion
The first day of the week is set in the WKO4 Preferences. For each date, this function gives the number of days after the first day of the week.

formatdate(datevalues, format)
Formats date/time values using a custom format specification string. The string can contain a combination of these variables:
yy
Two digit year with leading zero.
yyyy
Four digit year
M
Month number without leading zero.
MM
Month number with leading zero
MMM
Abbreviated month name
MMMM
Full month name
d
Day of month wihout leading zero.
dd
Day of month with leading zero
EEE
Abbreviated day of week.
EEEE
Full day of week.
h
Hour without leading zero, 012
hh
Hour with leading zero, 0012
H
Hour without leading zero, 024
HH
Hour with leading zero, 0024
m
Minute without leading zero.
mm
Minute with leading zero.
s
Seconds without leading zero.
ss
Seconds with leading zero.
a
AM or PM
You can also include other text in the format string by enclosing it in single quotes. Two single quotes in a row will be translated as one single quote. There are a few characters that do not need to be enclosed in single quotes:
space :  . / ,
Parameters
datevalues
A single date, or set of date/time values.
format
A format specification string.
Return Value
Returns a string with the formatted date/time.
Examples
formatdate(today, "EEEE, MMMM dd, yyyy")
Gives todays date formatted similar to "Saturday, August 13, 2016".
formatdate(date, "EEE MM/dd/yy hh:mm:ssa")
Gives the date/time of a workout formatted similar to "Fri 08/12/16 01:21:06PM".
formatdate(date, "yyyyMMdd HH:mm:ss")
Gives the date/time of a workout formatted similar to "20160812 13:21:06".
formatdate(date, "h:mm 'o''clock'")
Gives the date/time of a workout formatted similar to "1:21 o'clock".

month(datevalues)
Get the month number for one or more dates.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the month number (a number between 1 and 12) for
datevalues
.Examples
Gives the number 8.
Gives the month number for today, a number between 1 and 12.
Athlete Level Examples
Gives the month number for the workout date of all the workouts int the selected range.

monthval(datevalues)
Takes a date value and converts it to a month value.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the month value for
datevalues
.Discussion
The
monthval
function converts the date value to a fractional number of months since January 1, 1901. This is different than themonth
function which only gives a number between 1 and 12. WKO4 displays a month value using the computer's regional settings when using the units "month" otherwise it shows a fractional number.Examples
Gives "November 2015" if the units are set to month, otherwise it gives the number 1,378.0666667.
trunc(monthval(date(2015, 11, 3)))
Gives "November 2015" if the units are set to month, otherwise it gives the number 1,378.
Gives the date of the first day of the current month.
date(trunc(monthval(today))+1)
Gives the date of the first day of the next month.
date(trunc(monthval(today))+1)1
Gives the date of the last day of the current month.

startofmonth(datevalues)
Get the date of first day of the month.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns a date value for the first day of the month for each datevalue.

startofweek(datevalues)
Get the month number for one or more dates.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the date of the first day of the week for each date in
datevalues
.Discussion
This could be useful when creating a date range in the RHE.
Examples
Gives the date of the first day in the current week.
startofweek(today) + 6
Gives the date of the last day in the current week.
startofweek(today) + 7
Gives the date of the first day in the next week.

startofyear(datevalues)
Get the date of the start of the year that contains
datevalues
.Parameters
datevalues
A single date, or set of dates.
Return Value
Returns January 1st of the year specified in
datevalues
.Discussion
This could be useful when creating a date range in the RHE.
Examples
Gives the first day of the current year.
Gives the last date of the current year.
startofyear(startofyear(today)1)
Both give the first day of the previous year.
startofyear(today)1
Gives the last day of the previous year.

week(datevalues)
Get the week number for one or more dates.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the week number (a number between 1 and 53) for
datevalues
.Discussion
This function gives a number according to the ISO8601 standard. It is a count of weeks starting on Monday, where the first week of the year is the week that contains that year's first Thursday (a minimum of four days in the first week).
Athlete Level Examples
month(date)
Gives the month number for the workout date of all the workouts int the selected range.

weekval(datevalues)
Takes a date value and converts it to a week value.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the week value for
datevalues
.Discussion
The
weekval
function converts the date value to a fractional number of weeks since January 1, 1901. Whereas theweek
function gives a number between 1 and 53, theweekval
function gives a month for a specific date to include the year, and then formats the number as "month yyyy" such as "March 2015".Examples
Gives "11/8/15" if the units are set to week, otherwise if the units are blank it gives the number 5,993.857.
trunc(weekval(date(2015, 11, 8)))
Gives "11/2/15" (a Monday) if the units are set to week, otherwise if the units are blank it gives the number 5,993. The
trunc
function removes the fractional part of the week. 
year(datevalues)
Get the year number for one or more dates.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the year number, a four digit number like 2016.
Examples
Gives the number 2017.
Gives the four digit year number for today.
Athlete Level Examples
Gives the year number for the workout date of all the workouts int the selected range.

yearval(datevalues)
Takes a date value and converts it to a year value.
Parameters
datevalues
A single date, or set of dates.
Return Value
Returns the year value for
datevalues
.Discussion
The
yearval
function converts the date value to a fractional number of years since January 1, 1901. Whereas theyear
function gives a number between 1980 and 2099, theyearval
function gives a the fractional number of years since January 1, 1901.Examples
Gives 2015 if the units are set to year, otherwise if the units are blank it gives the number 114.852.
trunc(yearval(date(2015, 11, 8)))
Gives 2015 if the units are set to year, otherwise if the units are blank it gives the number 114. The
trunc
function removes the fractional part of the year.
Logical

logicaland(lhs, rhs)
Evaluates a logical and, same as the
and
and&&
operators.Parameters
lhs
Left hand side operand.
rhs
Right hand side operand.
Return Value
Returns 1 if both
lhs
andrhs
are nonzero, otherwise returns 0.Discussion
The
and
and&&
operators both use thelogicaland
function. So that means that bothdate>today and plannedtss>100
anddate>today && plannedtss>100
are equivalent tologicaland(date>today, plannedtss>100)
. The logicaland function and equivalent operators are most often used with theif
function to create a compound condition, for example "if this and that".Athlete Level Examples
if(logicaland(date>today, plannedtss>100), plannedtss)
Gives the planned TSS for all workouts after today and have planned TSS greater than 100.

logicalor(lhs, rhs)
Evaluates a logical or, same as the
or
and
operators.Parameters
lhs
Left hand side operand.
rhs
Right hand side operand.
Return Value
Returns 1 if either
lhs
orrhs
are nonzero, otherwise returns 0.Discussion
The
or
and
operators both use thelogicalor
function. So that means that bothhastag("race") or has(title, "race")
andhastag("race")  has(title, "race")
are equivalent tologicalor(hastag("race"), has(title, "race"))
. The logicalor function and equivalent operators are most often used with theif
function to create a compound condition, for example "if this or that".
Mathematical

abs(numbers)
Calculates the absolute value of each number value in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The absolute value of each value in
numbers
.Examples
abs(3)
3
abs(3)
3
abs({1,1,0,3,3})
{1, 1, 0, 3, 3}
The absolute value of every value in
elevation
.See Also

add(lhs, rhs)

divide(lhs, rhs)

ln(numbers)
Gives the natural log of
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The natural log of
numbers
. 
log(numbers, base)
Gives the base
base
logarithm ofnumbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
base
The base of the logarithm.
Return Value
The log of
numbers
. 
log10(numbers)
Gives the base 10 logarithm of
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The log of
numbers
. 
multiply(lhs, rhs)

power(lhs, rhs)
Raise lhs to the power rhs.
Parameters
lhs
A single number, a set of numbers, or a numeric variable.
rhs
A single number, a set of numbers, or a numeric variable.
Return Value
The value of lhs raised to the rhs power.
See Also

sign(numbers)

sqrt(numbers)

subtract(lhs, rhs)
Subtracts rhs from lhs.
Parameters
lhs
A single number, a set of numbers, or a numeric variable.
rhs
A single number, a set of numbers, or a numeric variable.
Return Value
The difference of lhs minus rhs.
See Also
PowerDuration

fibertype(meanmaxcurve)
Get the estimated % type I muscle fiber area (slowtwitch) based on a mean maximal curve.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.Return Value
The estimated % type I muscle fiber area.
Discussion
This function gives the percent of type I fast twitch musle fiber for the time period included in
meanmaxcurve
. It gives a single number for a meanmax curve, where the quality of the estimate is increased by including a representative sample of workouts in thatmeanmaxcurve
. Read the PowerDuration Metrics ebook.Examples
Gives the percent of type I slowtwitch muscle fiber for the meanmax curve.

fibertype(meanmaxcurve, lookback)
Get daily estimated % type I muscle fiber area (slowtwitch) based on a rolling window of
lookback
days.Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.lookback
The number of backward looking days.
Return Value
Daily estimated % percentages of type I slowtwitch muscle fiber, based on a rolling window of
lookback
days.Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the percentage of type II fibers. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook. 
frc(meanmaxcurve)
Get the Functional Reserve Capacity.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
ormeanmax(power/weight)
.Return Value
The Functional Reserve Capacity value in kJ or kJ/kg for
meanmaxcurve
.Discussion
This function gives the Functional Reserve Capacity for the time period included in the
meanmaxcurve
. It gives a single number for a meanmax curve, where the quality of the estimate is increased by including a representative sample of workouts in thatmeanmaxcurve
. Read the PowerDuration Metrics ebook.Examples
Gives the Functional Reserve Capacity in kJ.
Gives the Functional Reserve Capacity normalized to weight in kJ/kg.

frc(meanmaxcurve, lookback)
Get daily the Functional Reserve Capacity based on a rolling window of
lookback
days.Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.lookback
The number of backward looking days.
Return Value
Gives daily Functional Reserve Capacity values, one for each date in the selected RHE date range.
Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the FRC. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook. 
frce(meanmaxcurve)
Get the estimated error calculating Functional Reserve Capacity.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
ormeanmax(power/weight
.Return Value
Estimated error as +/ kJ orkJ/kg.
Discussion
This function calculates the estimated error when modeling FRC, in +/ kJ or kJ/kg. Read the PowerDuration Metrics ebook.

ftp(meanmaxcurve)
Get the modeled Functional Threshold Power.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
ormeanmax(power/weight)
.Return Value
The Functional Threshold Power value in W or W/kgfor
meanmaxcurve
.Discussion
This function gives the Functional Threshold Power for the time period included in the
meanmaxcurve
. It gives a single number for a meanmax curve, where the quality of the estimate is increased by including a representative sample of workouts in thatmeanmaxcurve
. Read the PowerDuration Metrics ebook.Examples
Gives modeled FTP in W.
Gives modeled FTP normalized for body weight in W/kg.

ftp(meanmaxcurve, lookback)
Get daily modeled FTP.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.lookback
The number of backward looking days.
Return Value
Gives daily Functional Threhold Power values, one for each date in the selected RHE date range.
Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the FTP. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook. 
ftpe(meanmaxcurve)
Get the estimated error calculating Functional Threshold Power.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.Return Value
One daily modeled FTP number for each date in the selected RHE date range.
Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the vo2max. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook. 
pdcurve(meanmaxcurve)
Generate a powerduration curve based on
meanmaxcurve
.Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.Return Value
A powerduration curve showing modeled power at a variety of durations.
Discussion
Read the PowerDuration Metrics ebook.
See Also

pdcurve(standardindex, gender)

pdprofile(meanmaxcurve)

phenotype(meanmaxcurve)

pmax(meanmaxcurve)

pmax(meanmaxcurve, lookback)

pmaxe(meanmaxcurve)

sumsqr(meanmaxcurve)

tte(meanmaxcurve)

tte(meanmaxcurve, lookback)

vo2max(meanmaxcurve)
Get daily VO2max in L/min.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.lookback
The number of backward looking days to include when calculating each daily vo2max.
Return Value
One daily vo2max number for each date in the selected RHE date range.
Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the vo2max. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook. 
vo2max(meanmaxcurve, lookback)
Get daily VO2max in L/min.
Parameters
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.lookback
The number of backward looking days to include when calculating each daily vo2max.
Return Value
One daily vo2max number for each date in the selected RHE date range.
Discussion
This function builds a meanmax curve for every date in the selected RHE date range, where each meanmax curve is comprised of the previous
lookback
days. Then from each daily meanmax curve it calculates the vo2max. Typical numbers to use forlookback
are between 30 and 90; larger numbers are chosen to capture bests at the largest variety of durations, but smaller numbers are used to be more sensitive to detraining. Read the PowerDuration Metrics ebook.
Rounding

ceil(numbers)
Calculate the ceiling of each value in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The smallest integer greater than or equal to each value in
numbers
. 
floor(numbers)
Calculate the floor of each value in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The largest integer less than or equal to each value in
numbers
. 
frac(numbers)
Get the fractional part of each value in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The fractional part of a number with the integer portion removed.
See Also

round(numbers)
Round each value in
numbers
to the nearest integer.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The numbers rounded to the nearest integer.
See Also

round(numbers, places)
Round each value in
numbers
to the specified number ofplaces
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
places
Position to round, where negative is to the right of the decimal point.
Return Value
The numbers rounded to the specified number of places.
See Also

trunc(numbers)
Truncate each value in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The integral part of a number with any fractional digits removed
Selection

athleterange(fromdate, todate, expression)

first(values, count)
Returns the first
count
values invalues
.Parameters
values
A single number, a set of numbers or strings, or a variable.
count
The count of values to return.
Return Value
The
count
first values invalues
.Discussion
The
first
function returns (X,Y) pairs ifvalues
contains (X,Y) pairs. When you graph an (X,Y) pair on a chart you get a single point, therefore you get a point for each of the first values found. If you include an (X,Y) pair in a report you'll see the value for X in the leftmost column.Examples
first({5,7,3,2,4,9,8}, 3)
{5, 7, 3}
first({"Yankee","Bravo","Zulu","Alpha","Foxtrot"},3)
{"Yankee", "Bravo", "Zulu"}
See Also

greatest(values, count)
Returns the greatest
count
values invalues
.Parameters
values
A single number, a set of numbers or strings, or a variable.
count
The count of values to return.
Return Value
The
count
greatest values invalues
.Discussion
The
greatest
function returns (X,Y) pairs ifvalues
contains (X,Y) pairs. When you graph an (X,Y) pair on a chart you get a single point, therefore you get a point for each of the greatest values found. If you include an (X,Y) pair in a report you'll see the value for X in the leftmost column. 
last(values, count)
Returns the last
count
values invalues
.Parameters
values
A single number, a set of numbers or strings, or a variable.
count
The count of values to return.
Return Value
The
count
last values invalues
.Discussion
The
last
function returns (X,Y) pairs ifvalues
contains (X,Y) pairs. When you graph an (X,Y) pair on a chart you get a single point, therefore you get a point for each of the last values found. If you include an (X,Y) pair in a report you'll see the value for X in the leftmost column.See Also

least(values, count)
Returns the least
count
values invalues
.Parameters
values
A single number, a set of numbers or strings, or a variable.
count
The count of values to return.
Return Value
The
count
least values invalues
.Discussion
The
least
function returns (X,Y) pairs ifvalues
contains (X,Y) pairs. When you graph an (X,Y) pair on a chart you get a single point, therefore you get a point for each of the least values found. If you include an (X,Y) pair in a report you'll see the value for X in the leftmost column. 
max(values)
Returns the greatest values in
values
.Parameters
values
A single number, a set of numbers or strings, or a variable.
Return Value
The greatest values in
values
.Discussion
The
max
function returns ( ,Y) with no X value. When you graph ( ,Y) on a chart you'll get a horizontal line.Examples
max({5,7,3,2,4,9,8})
9
Gives the maximum TSS number as a horizontal line.
Gives the maximum power number as a horizontal line.

max(values, groupby)

min(values)
Returns the least value in
values
.Parameters
values
A single number, a set of numbers or strings, or a variable.
Return Value
The least value in
values
.Discussion
The
min
function returns ( ,Y) with no X value. When you graph ( ,Y) on a chart you'll get a horizontal line. 
min(values, groupby)

workoutrange(fromtime, totime, expression)
Sorting and Reshaping

cross(values, values)
No longer used. You can use cartesian coordinate notation (X, Y) instead.

delta(numbers)
Gives the difference between each each number minus the previous number.
Parameters
numbers
A list of numbers.
Return Value
A list of numbers.
See Also

nozero(numbers)

resample(values, newrate)
Resamples time series data.

rev(values)
Reverses the order of values.
Parameters
values
A set of zero or more values.
Return Value
Returns values in reverse order.

shift(numbers, positions)

sort(values)

sortd(values)

string(values)
Converts number values to string values.
Parameters
values
A list of numbers.
Return Value
A list of strings.
Discussion
If you use the + operator to add numbers you get the result of adding the two, such as adding 2 + 3 you get 5. If you want to concatenate two or more values, then you need to convert them to strings first. For example, if you want to take 39 + 23 and get 3923 you first need to convert 39 and 23 to strings.

unique(values)
Gives only the unique values from a list.
Parameters
values
A list of strings or numbers.
Return Value
A list of values with duplicates removed.
Examples
Lists all the tags used in the currently selected workout or workout range.
See Also

xx(pairs)
Takes a set of (X,Y) values and copies X to Y to become (X,X).
Parameters
pairs
A set of X,Y pairs.
Return Value
Returns (X,Y) pairs as (X,X).
Examples
xx((37,52))
Takes the point (37,52) and changes it to (37,37).
meanmax((power)*xx((meanmax((power))/1000
Gives work expended at each point on a mean maximal power curve, where kJ = watts * seconds / 1000.
See Also

yx(pairs)
Takes a set of X,Y vales and exchanges X and Y to be come Y,X.
Parameters
pairs
A set of X,Y pairs.
Return Value
Returns (X,Y) pairs as (Y,X).
Examples
yx((37,52))
Takes the point (37,52) and changes it to (52,37).
Gives mean maximal power with power on the X axis and duration on the Y axis.
See Also
Statistical

avg(numbers)
Calculates the average of the numbers in
numbers
by taking their sum and dividing by their count.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The average of the values in
numbers
. 
bin(values, binsize)
Creates a histogram by placing values into specified bins and accumulating duration for each value.
Parameters
values
The values to place into bins.
binsize
The size of all bins.
Return Value
A set of values representing the duration in each bin.
Discussion
Each bin is uniform in size as specified.

bin(values, binvalues)
Creates a histogram by placing values into specified bins and accumulating duration for each value.
Parameters
values
The values to place into bins.
binvalues
A set of values representing cut points for the bins.
Return Value
A set of values representing the duration in each bin.
Discussion
Each bin contains the durations for values up to but not equal the value specified. There will be one bin for each value in
binvalues
plus one bin. For example, ifbinvalues
is{100, 200, 300}
thenvalues
will be placed into 4 bins as follows: less than 100, 100 to less than 200, 200 to less than 300, and 300 up.Examples
Creates 3 cadence bins: below 85, 85 up to 95, and 95 and above.
bin(power, {162, 184, 206, 228})
Bins power using a set of wattage numbers.
bin(power, {0.81, 0.92, 1.03, 1.14} * sftp)
Bins power using a set of percentages of sFTP.
sum(bin(heartrate, {0.82/3, 0.82*2/3, 0.82, (0.82+0.89)/2, 0.89, 0.94, 1.00, 1.03, 1.06} * thr) / 3600 * {20, 30, 40, 50, 60, 70, 80, 100, 120, 140})"hrTSS"
Calculates hrTSS using Friel bike heart rate levels.

bin(values, levelsname)
Creates a histogram by placing values into specified bins and accumulating duration for each value.
Parameters
values
The values to place into bins.
levelsname
The name of a training levels system.
Return Value
A set of values representing the duration in each bin.
Discussion
The bins are determined by training levels. When deciding into which level a value should be placed, WKO4 checks to see if the value is >= the "from", and < the "to". Thus, if one level is 110.0 to 131.0 and the next level is 131.0 to 144.0, then the value 131.0 will be placed into the second level, not the first.
Power levels:
 "cogganoptimized"
 "cogganclassic"
Heart Rate Levels:
 "cogganhr"
 "frielhr"
 "usachr"
 "bcfhr"
Running Pace Levels:
 "frielpace"
 "pzipace"

count(values)

count(values, groupby)

cumsum(numbers)
Gives the cumulative totals of the addition of all the values in the set of
numbers
.Parameters
numbers
A set of numbers.
Return Value
The sum of
numbers
.Examples
cumsum({1,2,3,4,5,6,7,8,9,10})
Gives the set {1,3,6,10,15,21,28,36,45,55}.
Gives cumulative distance, same as the variable elapseddistance.
cumsum(power * deltatime) / 1000
Gives cumulative work in kJ.
cumsum(if(_elevationshift(_elevation,1)>0,_elevationshift(_elevation,1)))
Gives cumulative climbing.
See Also

li(pairs, numbers)
Finds Y values for a given X value using linear interpolation if necessary.
Parameters
pairs
A set of X,Y pairs.
numbers
A single number or set of numbers representing X values for which you wish to find the corresponding Y values.
Return Value
A set of Y values corresponding to the X values given in
numbers
.Discussion
Linear interpolation can be helpful to find the exact or approximate Y value using the points nearest the specified X values.
Examples
li(elapseddistance, 0:10:00)
At the workout level, gives the distance at 10 minutes.
li(yx(metric(elapseddistance)),40.0)
At the workout level, gives the elapsed duration at 40km.
li(pdcurve(meanmax(power)),0:20:00)*0.92
Gives 92% of the modeled 20 minute power.
li(pdcurve(meanmax(power)),{60,360,1200})
Gives modeled power at 1min, 5min, and 20min.
li(yx(pdcurve(meanmax(power))),last(sftp,1)*1.2)
Gives modeled duration at 120% of sftp.

meanmax(pairs)
Searches pairs for durations with maximum average, and creates a mean maximal curve.
Parameters
pairs
A set of pairs, usualy having elapsedtime, elapseddistance, or date for the x value.
Return Value
A mean maximal curve, which is a set of pairs with duration as x and average as y.
Discussion
A mean maximal search finds continuous durations with the highest average.
Examples
meanmax(power)
Mean maximal power curve
meanmax(power/weight)
Mean maximal power to weight curve.
meanmax(tss)
Mean maximal tss curve.
meanmax(if(cumsum(bikepower*deltatime)/1000>1500,bikepower))
Mean maximal power curve including power only after accumulating 1500kJ.
See Also

meanmax(pairs, duration)
Calculates the absolute value of each number value in
numbers
.Parameters
pairs
A set of pairs, usualy having elapsedtime, elapseddistance, or date for the x value.
duration
One or more numbers specifying a specific duration to search for.
Return Value
The mean maximal for each duration specified.
Examples
Gives the best average power for a continuous 20 minute (1200 seconds) duration.
Gives the best 10 minute (600 seconds) pace.
meanmax(if(_elevationshift(_elevation,1)>0,metric(_elevationshift(_elevation,1))/deltatime*3600,0),300)
Searches for the 5 minute period with the highest average VAM.
metric(60/greatest(meanmax((metric(elapseddistance),runspeed), 5.0), 3))
Gives the 3 fastest 5K run pace in min/km.

meanmaxfrom(pairs, duration)
Searches for the begin time offset for the mean maximal value.
Parameters
pairs
A set of pairs, usualy having elapsedtime, elapseddistance, or date for the x value.
duration
One or more numbers specifying a specific duration to search for.
Return Value
The beginning elapsed time for the mean maximal for each duration specified.
Examples
meanmaxfrom(power, 0:20:00)
Gives the start time of the 20 minute duration with the highest average power.

meanmaxto(pairs, duration)
Searches for the end time offset for the mean maximal value.
Parameters
pairs
A set of pairs, usualy having elapsedtime, elapseddistance, or date for the x value.
duration
One or more numbers specifying a specific duration to search for.
Return Value
The ending elapsed time for the mean maximal for each duration specified.
Examples
Gives the end time of the 20 minute duration with the highest average power.

pstddev(numbers)
Calculates the population standard deviation of numbers.
Parameters
numbers
A set of numbers.
Return Value
The population standard deviation.
Examples
pstddev({1,2,3,4,5,6,7,8,9,10})
Gives the number 2.8722813.
Gives the population standard deviation of power data.
See Also

recordingrate
Gets the recording rate of time series data.

slr(numbers)
Calculates the simple linear regression for the values in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The absolute value of each value in
numbers
. 
slrb(numbers)
Calculates the Yintercept of the simple linear regression for the values in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The Yintercept of the simple linear regression

slrm(numbers)
Calculates the slope of the simple linear regression for the values in
numbers
.Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The slope of the simple linear regression.

slrrsq(numbers)
Calculates the R² value for the simple linear regression. R² is a measure of how close the data are to the fitted regression line.
Parameters
numbers
A single number, a set of numbers, or a numeric variable.
Return Value
The R² of the simple linear regression.

stddev(numbers)
Calculates the sample standard deviation of numbers.
Parameters
numbers
A set of numbers.
Return Value
The sample standard deviation.
Examples
stddev({1,2,3,4,5,6,7,8,9,10})
Gives the number 3.0276504.
Gives the sample standard deviation of power above sFTP.
See Also

sum(numbers)

sum(numbers, groupby)
Gives the total of the addition of all the values in the set of
numbers
, grouped bygroupby
.Parameters
numbers
A set of numbers.
period
A period identified by "day", "week", "month" or "year".
Return Value
Count of values grouped by groupby.
See Also
Training Levels

levelfrom(levelsname, index)
Gives the low limit of a training level.
Parameters
levelsname
The name of a training levels system.
index
The index of the level.
Return Value
The low limit of a training level.
Discussion
The first level in any system begins with
index
0. The levels you can use for thelevelsname
parameter are as follows.Power levels:
 "cogganoptimized"
 "cogganclassic"
Heart Rate Levels:
 "cogganhr"
 "frielhr"
 "usachr"
 "bcfhr"
Running Pace Levels:
 "frielpace"
 "pzipace"

levelname(levelsname, index)
Gives the name of a training level.
Parameters
levelsname
The name of a training levels system.
index
The index of the level.
Return Value
The name of a specific training level within the traning levels system.
Discussion
The first level in any system begins with
index
0. The levels you can use for thelevelsname
parameter are as follows.Power levels:
 "cogganoptimized"
 "cogganclassic"
Heart Rate Levels:
 "cogganhr"
 "frielhr"
 "usachr"
 "bcfhr"
Running Pace Levels:
 "frielpace"
 "pzipace"
Examples
levelname("cogganclassic",1)
Gives the name of the second Coggan Classic Power level, which is "Endurance".

levelto(levelsname, index)
Gives the high limit of a training level.
Parameters
levelsname
The name of a training levels system.
index
The index of the level.
Return Value
The high limit of a training level.
Discussion
The first level in any system begins with
index
0. The levels you can use for thelevelsname
parameter are as follows.Power levels:
 "cogganoptimized"
 "cogganclassic"
Heart Rate Levels:
 "cogganhr"
 "frielhr"
 "usachr"
 "bcfhr"
Running Pace Levels:
 "frielpace"
 "pzipace"

targetduration(levelindex, meanmaxcurve)
Gives the target duration for a given level.
Parameters
levelindex
The index of the level, a number between 0 and 5.
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.Return Value
Target duratin for the level.
Discussion
The first level begins with
levelindex
0.0
Extensive Aerobic (FTP)
1
Intenisve Aerobic (FTP)
2
Max Aerobic (VO2 Max Intensive)
3
Extensive Anaerobic (FRC)
4
Intensive Anaerobic (FRC)
5
Max
Examples
targetduration(3,meanmax(power))
Gives the target duration for level 3, Extensive Anaerobic (FRC).

targetname(levelindex)
Gives the name of a target level.
Parameters
levelindex
The index of the level, a number between 0 and 5.
Return Value
The name of the specified level.
Discussion
The first level begins with
levelindex
0.0
Extensive Aerobic (FTP)
1
Intenisve Aerobic (FTP)
2
Max Aerobic (VO2 Max Intensive)
3
Extensive Anaerobic (FRC)
4
Intensive Anaerobic (FRC)
5
Max

targetpower(levelindex, meanmaxcurve)
Gives the target power for a given level.
Parameters
levelindex
The index of the level, a number between 0 and 5.
meanmaxcurve
Mean maximal power curve data, usually
meanmax(power)
.Return Value
Target power for the level.
Discussion
The first level begins with
levelindex
0.0
Extensive Aerobic (FTP)
1
Intenisve Aerobic (FTP)
2
Max Aerobic (VO2 Max Intensive)
3
Extensive Anaerobic (FRC)
4
Intensive Anaerobic (FRC)
5
Max
Examples
targetpower(3,meanmax(power))
Gives the target power for level 3, Extensive Anaerobic (FRC).
Units

english(numbers)
Converts numbers to the English units system.
Parameters
numbers
A set of numbers.
Return Value
Converted
numbers
.Discussion
If the units of
numbers
is one of the following, the value is converted to its English equivalent. Otherwise no conversion is applied.km
mi
min/km
min/mi
m
ft
kg
lb
N
lbf
km/h
mi/h
°C
°F
cm
in
Examples
If the default units system is metric, converts the temperature data channel from °C to °F.
See Also

metric(numbers)
Converts numbers to the metric units system.
Parameters
numbers
A set of numbers.
Return Value
Converted
numbers
.Discussion
If the units of
numbers
is one of the following, the value is converted to its metric equivalent. Otherwise no conversion is applied.mi
km
min/mi
min/km
ft
m
lb
kg
lbf
N
mi/h
km/h
°F
°C
in
cm
Examples
If the default units system is English, converts the workout distance data channel from mi to km.
See Also
All Functions
abs(numbers)
add(lhs, rhs)
athleterange(fromdate, todate, expression)
avg(numbers)
bin(values, binsize)
bin(values, binvalues)
bin(values, levelsname)
ceil(numbers)
count(values)
count(values, groupby)
cross(values, values)
cumsum(numbers)
date(value)
date(year, month, day)
day(datevalues)
dayofweek(date)
delta(numbers)
divide(lhs, rhs)
english(numbers)
ewma(numbers,constant)
fibertype(meanmaxcurve)
fibertype(meanmaxcurve, lookback)
filter(numbers, kernel, sides)
first(values, count)
floor(numbers)
formatdate(datevalues, format)
frac(numbers)
frc(meanmaxcurve)
frc(meanmaxcurve, lookback)
frce(meanmaxcurve)
ftp(meanmaxcurve)
ftp(meanmaxcurve, lookback)
ftpe(meanmaxcurve)
gaussian(sigma, length)
greatest(values, count)
has(string, substring)
hastag(string)
if(condition, truevalue)
if(condition, truevalue, falsevalue)
isef(factor, length)
isvalid(numbers)
last(values, count)
least(values, count)
levelfrom(levelsname, index)
levelname(levelsname, index)
levelto(levelsname, index)
li(pairs, numbers)
ln(numbers)
log(numbers, base)
log10(numbers)
logicaland(lhs, rhs)
logicalor(lhs, rhs)
max(values)
max(values, groupby)
meanmax(pairs)
meanmax(pairs, duration)
meanmaxfrom(pairs, duration)
meanmaxto(pairs, duration)
metric(numbers)
min(values)
min(values, groupby)
month(datevalues)
monthval(datevalues)
multiply(lhs, rhs)
nozero(numbers)
pdcurve(meanmaxcurve)
pdcurve(standardindex, gender)
pdprofile(meanmaxcurve)
phenotype(meanmaxcurve)
pmax(meanmaxcurve)
pmax(meanmaxcurve, lookback)
pmaxe(meanmaxcurve)
power(lhs, rhs)
pstddev(numbers)
recordingrate
resample(values, newrate)
rev(values)
round(numbers)
round(numbers, places)
shift(numbers, positions)
sign(numbers)
slr(numbers)
slrb(numbers)
slrm(numbers)
slrrsq(numbers)
sort(values)
sortd(values)
sqrt(numbers)
startofmonth(datevalues)
startofweek(datevalues)
startofyear(datevalues)
stddev(numbers)
string(values)
subtract(lhs, rhs)
sum(numbers)
sum(numbers, groupby)
sumsqr(meanmaxcurve)
targetduration(levelindex, meanmaxcurve)
targetname(levelindex)
targetpower(levelindex, meanmaxcurve)
tl(numbers, constant)
trunc(numbers)
tte(meanmaxcurve)
tte(meanmaxcurve, lookback)
unique(values)
vo2max(meanmaxcurve)
vo2max(meanmaxcurve, lookback)
week(datevalues)
weekval(datevalues)
workoutrange(fromtime, totime, expression)
xx(pairs)
year(datevalues)
yearval(datevalues)
yx(pairs)
Variables
Channel Variables
Channel variables can be prefixed with bike, run, swim, row, ski, other to make them specific to a sport type.

_elevation
Smoothed elevation values.
Units
In metric elevation is given in meters, and in English it's given in feet.

balance

cadence

crankposition

effectivenessleft

effectivenessright

elapseddistance

elapsedtime

elevation
Elevation values as recorded by a device.
Units
In metric elevation is given in meters, and in English it's given in feet.

forceleft

forceright

frontgear
Gives the number of teeth on the front chainring selected.
Units
The front gear selection is given by the number of teeth on the chainring.
See Also

heartrate

latitude

leftpco
Left side platform center offset.

leftppend
Left side power phase end angle.

leftpppend
Left side power phase peak start angle.

leftpppstart
Left side power phase peak start angle.

leftppstart
Left side power phase start angle.

longitude

power

reargear
Gives the number of teeth on the rear cog selected.
Units
The rear gear selection is given by the number of teeth on the rear cog.
See Also

rightpco
Right side platform center offset.

rightppend
Right side power phase end angle.

rightpppend
Right side power phase peak start angle.

rightpppstart
Right side power phase peak start angle.

rightppstart
Right side power phase start angle.

runsmoothness

sathb
Saturation of O₂ as a percent.

smoothness

smoothnessleft

smoothnessright

speed

stancetime

stancetimepercent

strokecount

stroketype

temperature

torque

torqueleft

torqueright

totalhb
Total concentration of hemoglobin.

verticaloscillation
Workout Variables

build

channels

code

date

desc

description

devices

filepath

notes

planneddistance

plannedduration

plannedtss

plannedwork

sport
Discussion
The
sport
variable gives the category of sport type (subsport
) assigned to a workout. This is useful when you want to reference all sport types within a broader category without having to reference eachsubsport
within that category.bike
All sports riding a bike: Road Bike, Mountain Bikerun
Weightbearing sports: Run, Walkswim
Swimming sports: Swimrow
Sports in water craft propelled with a blade or paddle: Rowxc ski
Skiing: XC Skiother
Nonendurance sports: Day Off, Strength, Other
See Also

subsport
Discussion
The
subsport
variable gives the specific sport type assigned to a workout.Road Bike
Mountain Bike
Run
Walk
Swim
Row
XC Ski
Day Off
Strength
Other
See Also

tags

title
All Variables
_elevation
aepf
age
atl
atlconstant
balance
begindate
begindistance
begintime
build
cadence
channels
climbing
code
cpv
cranklength
crankposition
ctl
ctlconstant
date
deltadistance
deltatime
desc
descending
description
devices
distance
duration
e
ecpower
ef
effectivenessleft
effectivenessright
elapseddistance
elapsedduration
elapsedtime
elevation
elevationchange
enddate
enddistance
endtime
filepath
firstworkoutdate
forceleft
forceright
frontgear
g
gender
gpaleft
gparight
gprleft
gprright
grade
heartrate
if
kileft
kiright
lastworkoutdate
latitude
leftpco
leftppend
leftpppend
leftpppstart
leftppstart
longitude
mepfleft
mepfright
mhr
movingduration
na
ngp
notes
np
pahr
pedalingduration
pi
planneddistance
plannedduration
plannedtss
plannedwork
power
pwhr
rampconstant
ramprate
reargear
rgrade
rightpco
rightppend
rightpppend
rightpppstart
rightppstart
rngp
runsmoothness
sathb
sftp
smoothness
smoothnessleft
smoothnessright
speed
sport
stamina
stancetime
stancetimepercent
strokecount
stroketype
subsport
tags
tcadence
temperature
thr
title
today
torque
torqueleft
torqueright
totalhb
trunpace
tsb
tss
tssduration
tswimpace
vam
verticaloscillation
vi
weight
work
Operators

!
Evaluates unary not value.
Examples
!0
1
!1
0

!=
Compares lhs not equal to rhs.
Examples
1!=2
1
5!=3
1
7!=7
0

&&
Evaluates lhs and rhs.
Examples
1 && 1
1
1 && 0
0
0 && 1
0
0 && 0
0

*
Multiplies lhs * rhs.
Examples
7*5
35
6*0
0

+
Adds lhs + rhs.
Examples
1+2
3
4+0
4


Subtracts lhs  rhs.
Examples
12
 1
43
1

/
Divides lhs / rhs.
Examples
1/2
0.5
7/5
1.4
3/0
Undefined ()

<
Compares lhs less than rhs.
Examples
1<2
1
5<3
0
7<7
0

<=
Compares lhs less than or equal to rhs.
Examples
1<=2
1
5<=3
0
7<=7
1

<>
Compares lhs not equal to rhs.
Examples
1!=2
1
5!=3
1
7!=7
0

=
Compares lhs equal to rhs.
Examples
1!=2
1
5!=3
1
7!=7
0

==
Compares lhs equal to rhs.
Examples
1==2
0
5==3
0
7==7
1

>
Compares lhs greater than rhs.
Examples
1>2
0
5>3
1
7>7
0

>=
Compares lhs greater than or equal to rhs.
Examples
1>=2
0
5>=3
1
7>=7
1

^
Calculates lhs ^ rhs, which raises lhs to the rhs power.
Examples
4^2
16
3^5
243
64^(1/2)
8

and
Evaluates lhs and rhs.
Examples
1 and 1
1
1 and 0
0
0 and 1
0
0 and 0
0

not
Evaluates unary not value.
Examples
not 0
1
not 1
0

or
Evaluates lhs or rhs.
Examples
1 or 1
1
1 or 0
1
0 or 1
1
0 or 0
0


Evaluates lhs or rhs.
Examples
1  1
1
1  0
1
0  1
1
0  0
0
Data Types

Date
A date formatted according to the computer's regionol settings. Examples are:
11/5/1967
5/11/67

Number
A positive or negative real number composed of the digits 09, decimal point, and positive or negative sign. Examples are:
1
1.
1.0
+0.9
.765
1234.56

Pair
An (x,y) ordered pair of data items. Examples are:
(123, 456)
A point at coordinates x=123 and y=456.
( , 456)
A horizontal line at y=456.
(789, )
A vertical line at x=789.

Set
A list of zero or more data items of any type enclosed in brackets and separated by commas. Examples are:
{}
An empty set.
{1, 2, 3, 4.5, 5}
A set of 5 numbers.
{"Recovery", Endurance", "Threshold"}
A set of three strings.
There are also some shortcuts for entering pairs. One form is {from:to:step}. Examples are:
{3:6}
{3,4,5,6}
{1:10:2}
{1, 3, 5, 7, 9}
{12:3:4,1,2,3}
{12, 8, 4, 1, 2, 3}
Another form is {value;repeat}. Examples are:
{5;3}
{5,5,5}
{7;4,5,3,1}
{7,7,7,7,5,3,1}
{11;3,13;4}
{11, 11, 11, 13, 13, 13, 13}

String
A list of zero or more characters enclosed in double quotes. Examples are:
"cogganoptimized"
"Endurance"
""

Time
A time or duration formatted according to the computer's regionol settings. Examples are:
1:00:00
0:20:00
0:00:01
Syntax/Grammar
expression  atom[yunits][binaryoperator expression] 
atom  pair 
 unaryoperator expression 
 numberliteral 
 dateliteral 
 timeliteral 
 stringliteral 
 setliteral 
 variable 
 function 
unaryoperator  ! 
 not 
 + 
  
binaryoperator  ^ 
 * 
 / 
 + 
  
 < 
 <= 
 > 
 >= 
 != 
 <> 
 = 
 == 
 and 
 && 
 or 
  
yunits  stringliteral 
pair  (expression, expression) 
 (expression, ) 
 ( , expression) 
 see Pair 
stringliteral  see String 
numberliteral  see Number 
dateliteral  see Date 
timeliteral  see Time 
setliteral  { [setexpr [,setexpr]... ] } 
 see Set 
setexpr  expression 
 expression:expression[:expression] 
 expression;expression 
variable  [_az][az09] 
 see Variables 
function  [_az][az09] ( [parameterlist] ) 
 see Functions 
parameterlist  expression[, parameterlist] 