Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, please, does anyone know how to bring the last month sales In M Language using this columns as example? the column A is the date and the column B is the Sales Amount.
Hi @Anonymous ,
If you just want to filter the table to the latest month, then the following custom step would work:
Table.SelectRows(
PreviousStepName,
each [data real calculada] = List.Max(PreviousStepName[data real calculada])
)
Pete
Proud to be a Datanaut!
Hi, i tried to use that one you wrote but didn't work out, because in fact, what i want is bring the sales from last month, so it would be like a function to calculate the sales, but combine with some date function to make sure that i would bring the sales only one month before.
Here's a DAX example that explain exactly what i need to be done in M Language:
Ah, ok. So the DATEADD 'equivalents' in Power Query would be Date.AddDays, Date.AddMonths, or Date.AddYears.
To filter the table to the prior month relative to today's date/month, assuming your date column always only contains the last date of each month, you would need to find the first day of the current month, take one month from that, then get the last date of that month to filter on, so it would look something like this:
Table.SelectRows(
PreviousStepName,
each [data real calculada] =
Date.EndOfMonth( Date.AddMonths( Date.StartOfMonth( Date.From(DateTime.LocalNow())), -1))
)
If you want to completely replicate the CALCULATE function and return a scalar value, you would use this filter in conjunction with a Group By or a Statistics function from the Transform tab. However, Power Query isn't designed to be used in this way, so I'd recommend keeping calculational processes in DAX.
Pete
Proud to be a Datanaut!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
11 | |
9 | |
6 | |
6 |