Forum Discussion
Filter rows
- 7 months ago
To filter out the current month, you need to use the Advanced Editor with a line like:
#"Remove Current Month" = Table.SelectRows(#"Previous Step", each [Dates] < Date.StartOfMonth(Date.From(DateTime.LocalNow())))Replace #"Previous Step" with the obvious.
You could also add a Choose Rows step from the UI, and, in the formula bar, edit what you see to show the above selection criteria.
Here is an example, including creating a column of dates spanning several years, that will return only the rows with months in the current fiscal year excepting the current month:
let fyStart=[a=Date.From(DateTime.FixedLocalNow()), b=Date.Month(a), c=Date.Year(a), d=if b < 9 then #date(c-1,9,1) else #date(c,9,1)][d], //Create table with date column over several fiscal years Source = #table(type table[Date=date],List.Accumulate({1..36},{}, (s,c)=>s & {{Date.AddMonths(#date(2023,1,1),c)}})), //Select current fiscal year except current month #"Current FY" = Table.SelectRows(Source, each [Date]>=fyStart and [Date] < Date.StartOfMonth(Date.From(DateTime.FixedLocalNow()))) in #"Current FY"Source Table:
Results:
To filter out the current month, you need to use the Advanced Editor with a line like:
#"Remove Current Month" = Table.SelectRows(#"Previous Step", each [Dates] < Date.StartOfMonth(Date.From(DateTime.LocalNow())))
Replace #"Previous Step" with the obvious.
You could also add a Choose Rows step from the UI, and, in the formula bar, edit what you see to show the above selection criteria.
Here is an example, including creating a column of dates spanning several years, that will return only the rows with months in the current fiscal year excepting the current month:
let
fyStart=[a=Date.From(DateTime.FixedLocalNow()),
b=Date.Month(a),
c=Date.Year(a),
d=if b < 9 then #date(c-1,9,1) else #date(c,9,1)][d],
//Create table with date column over several fiscal years
Source = #table(type table[Date=date],List.Accumulate({1..36},{},
(s,c)=>s & {{Date.AddMonths(#date(2023,1,1),c)}})),
//Select current fiscal year except current month
#"Current FY" = Table.SelectRows(Source, each [Date]>=fyStart and [Date] < Date.StartOfMonth(Date.From(DateTime.FixedLocalNow())))
in
#"Current FY"
Source Table:
Results: