Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Good Morning All,
I have a sales export file from SAP, which I wonder why they put this layout but anyway
I have managed to do some transformations and I have now a column with the Year, Month, Month Number
My goal is to have the sales for the latest three month of the current year, compared to the same three month the year before
My sales export is back to November 2021
What I did :
I used Record.Field along with Table.Max to get the highest value in my column Year and I did the same to get the Year -1
Now I would like to keep the latest three months but am not sure how to do it
Overall, if you have a suggestion to help me to reach my goal I'll be happy
Daniel
Solved! Go to Solution.
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))
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
@v-stephen-msft 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
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.
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))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.