Probably one for @Melissa, this one.
I’m trying to set up a Fiscal Period offset. The normal extended date table doesn’t require this because it works on calendar months and the month offset is the same. However, I am in the middle of setting up a 445 table in SQL and PQ and the Fiscal Period offset will be different from the month offset.
I have something which works but there might be a smarter way to do this.
My approach is to set up an indexed table with FPeriodnYear, IsCurrentFP.
let
Source = #"Date Generator"(Date.AddYears(CalendarStart,-2), BudgetYearEnd, FiscYearStartMonth, OfficialHolidays[OfficialHoliday], null),
#"Removed Other Columns" = Table.Distinct(Table.SelectColumns(Source,{"FPeriodnYear", "IsCurrentFP"})),
#"Indexed FPnYear" = Table.AddIndexColumn(#"Removed Other Columns", "Index", 0, 1, Int64.Type)
in
#"Indexed FPnYear"
Then reference this and find current year index
Source = AllFIscalPeriodnYearIndex,
#"Filtered Rows" = Table.SelectRows(Source, each ([IsCurrentFP] = true)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"FPeriodnYear", "IsCurrentFP"}),
Index = #"Removed Columns"{0}[Index]
in
Index
type or paste code here
Merge this with the main date table and perform the subtraction.
This does work but there may be a more optimal way to do this in the date function?
Pete