Forum Discussion
Keep the N highest/lowest value
- 4 years ago
To get the numbers of this year past 3 months and last year past three months you can create a custom filter to be used with Table.SelectRows.
Assuming you have a "Date" column, something like:
//create custom filter //current "last three months" dtCurrentEnd = Date.From(Date.StartOfMonth(DateTime.LocalNow())), dtCurrentStart = Date.From(Date.AddMonths(dtCurrentEnd,-3)), //previous year same three months dtPrevEnd = Date.AddYears(dtCurrentEnd,-1), dtPrevStart = Date.AddYears(dtCurrentStart,-1), //then filter the table yrToyr = Table.SelectRows(#"Changed Type", each ([Date] >=dtCurrentStart and [Date] < dtCurrentEnd) or ([Date]>=dtPrevStart and [Date]< dtPrevEnd)) - Anonymous4 years ago
Hi AtoBI ,
You can filter the first three months data directly as follows.
Selcet 'In the Previous...'
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ronrsnfld thanks for your solution it worked for me
Anonymous thanks for your time and proposition. However, if am not mistaken, your solution works if I want to keep the last three months on a specific year. I wanted to keep the last three months of the current year and the same three months of the past year
Thanks all