Date & time

MonthStart, AddMonths, YearToDate, Date# parsing, NetWorkDays and building a calendar table.

MonthStart(date [, period_no]) MonthStart, MonthEnd and period boundaries MonthStart and MonthEnd return the first or last millisecond of a month. Use Date.StartOfMonth and Date.EndOfMonth in Power Query, or EOMONTH in DAX. Note that STARTOFMONTH in DAX is a table function, not the same thing. Direct equivalent AddMonths(startdate, n [, mode]) AddMonths AddMonths shifts a date by n months. EDATE (DAX) and Date.AddMonths (M) do the same with mode 0 semantics. Mode 1 (end-relative) needs a few extra lines. DAX DATEADD is not the same function. Direct equivalent YearToDate(date [, yearoffset [, firstmonth [, todaydate]]]) YearToDate flags and YTD 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. Partial / different approach Date(Date#(text, 'YYYYMMDD'), 'DD-MM-YYYY') Date#() parsing and Date() formatting Date#() interprets text as a date and Date() formats a number as a date, keeping it a dual. In Power BI, parse in Power Query with Date.FromText and set the display format on the column. DAX FORMAT() turns a date into text. Partial / different approach NetWorkDays(start, end [, holiday...]) NetWorkDays (working days) NetWorkDays counts Monday-to-Friday working days between two dates, minus listed holidays. DAX has NETWORKDAYS with configurable weekends and a holiday table. A working-day flag on the date table is often the more maintainable option. Direct equivalent 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