YearToDate(date [, yearoffset [, firstmonth [, todaydate]]])
YearToDate flags and YTD in Power BI
Qlik's YearToDate() flag is relative to the reload date. DAX TOTALYTD is relative to the dates in the filter context. Pick the one that matches what users expect, or rebuild the flag as a calculated column.
What it does in Qlik
YearToDate(timestamp, ...) returns true (-1) if the date falls between 1 January (or firstmonth) and the last script execution, inclusive. yearoffset = -1 gives the same period last year. It is usually stored as a flag field in the script and used in set analysis.
Qlik example
// script, in the master calendar
-YearToDate(Date) AS IsYTD,
-YearToDate(Date, -1) AS IsPYTD,
-YearToDate(Date, 0, 7) AS IsFYTD // fiscal year starting in July
// chart
Sum({<IsYTD={1}>} Sales)Power BI equivalent
Time intelligence (relative to the filter context)
Sales YTD = TOTALYTD ( [Sales], 'Date'[Date] )
Sales PYTD = CALCULATE ( [Sales YTD], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
Sales FYTD = TOTALYTD ( [Sales], 'Date'[Date], "6-30" )Refresh-time flags (Qlik's behaviour)
Calculated columns are evaluated at refresh, so TODAY() here plays the role of Qlik's reload timestamp.
Is YTD =
'Date'[Date] >= DATE ( YEAR ( TODAY () ), 1, 1 ) && 'Date'[Date] <= TODAY ()
Is PYTD =
'Date'[Date] >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 ) && 'Date'[Date] <= EDATE ( TODAY (), -12 )
Sales YTD (flag) = CALCULATE ( [Sales], 'Date'[Is YTD] = TRUE () )Gotchas and behaviour differences
- With the full current year selected,
TOTALYTDruns to 31 December, so it equals the full year to date of data, not "to today". Future dates without sales don't add anything, but a PYTD comparison will include the whole of last year. Limit it to dates with data, or use the flag. TODAY()in the Power BI service uses UTC. Qlik's defaulttodaydateis also the reload time in UTC, so the two agree. Around midnight, both can differ from local time.- Time intelligence functions need a contiguous, marked date table.
Official documentation
- yeartodate - script and chart function (Qlik Help)
- TOTALYTD function (DAX) (Microsoft Learn)
- DATESYTD function (DAX) (Microsoft Learn)
- TODAY function (DAX) (Microsoft Learn)
- TOTALYTD (dax.guide)
Related pages
LOAD ... AUTOGENERATE ... WHILE ... IterNo()
Master calendar (date table)
The Qlik master calendar script maps to a date table built in Power Query (List.Dates) or DAX (CALENDAR), marked as a date table and related to the fact date. It is essential for every time-intelligence function.
Direct equivalent
Sum({<Year={$(=Max(Year))}>} Sales)
Dollar-sign expansion in sets: $(=Max(Year))
Dollar-sign expansions such as $(=Max(Year)) put a calculated value into a set expression. In DAX you use a variable, but it is evaluated per cell, not once per chart.
Partial / different approach
RangeSum(Above(Sum(Sales), 0, RowNo()))
Running totals with RangeSum(Above(...))
The Qlik running-total idiom RangeSum(Above(Sum(Sales), 0, RowNo())) maps to a cumulative DAX measure, a WINDOW function, or the RUNNINGSUM visual calculation.
Partial / different approach
Spotted an error or a better pattern? QlikToDax is maintained by a working BI consultant; corrections are welcome via the About page. Last reviewed 2026-10-25.