Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
I have last 2 months data based on current day but M-Query previous month filter is not working like SQL Database for Previous 2 months and it is giving the data from Aug1st2020 instead of Aug15th2020.
Could you please let me know how to restrict the exact last 2 months data(From Aug15th2020) based on current day.
Solved! Go to Solution.
Use Date.AddMonths. See below:
Date.AddMonths([Date], -2)
That will move the date exactly 2 months back where possible. Notice how I moved Oct 31 1 month ago. There's no September 31, so he moved it to September 30 in that case.
To use it as a filter using today's date, you can use this:
= Table.SelectRows(#"Added Custom1", each [Two Months back] >= Date.AddMonths(DateTime.Date(DateTime.LocalNow()), -2))
That will make it all August 15, 2020 and later.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingUse Date.AddMonths. See below:
Date.AddMonths([Date], -2)
That will move the date exactly 2 months back where possible. Notice how I moved Oct 31 1 month ago. There's no September 31, so he moved it to September 30 in that case.
To use it as a filter using today's date, you can use this:
= Table.SelectRows(#"Added Custom1", each [Two Months back] >= Date.AddMonths(DateTime.Date(DateTime.LocalNow()), -2))
That will make it all August 15, 2020 and later.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingThank you so much it is working ...
Hi, @Narukkp
Could you please tell me whether your problem has been solved?
If it is, please mark the helpful replies or add your reply as Answered to close this thread.
If you haven't, please share more details.
Best Regards,
Community Support Team _ Eason
Thanks for your reply , but i required the two months back data based on table column i.e i have a table called sales trans and it is having the Invoice Date , so i reuqired the last 2 months invoice dates.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 136 | |
| 102 | |
| 68 | |
| 66 | |
| 58 |