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,
I am trying to add a column via Power Query M. How do I convert this DAX code to M language:
IF (
YEAR ( 'Dummy Data'[Admissions Month] )
= YEAR ( DATE(YEAR(TODAY()),
MONTH(TODAY())-1,DAY(TODAY())) )
&& MONTH ( 'Dummy Data'[Admissions Month] ) = MONTH ( DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())) ),
"Last Month",
'Dummy Data'[Admissions Month]
)
Thanks for your help.
Solved! Go to Solution.
Hi @JohnNPBIUser ,
I think you can hugely simplify this down to:
if Date.StartOfMonth([AdmissionsMonth]) = Date.StartOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()), -1))
then "Last Month"
else [AdmissionsMonth]
Pete
Proud to be a Datanaut!
Thank you for your help, much appreciated 👍
Hi @JohnNPBIUser ,
I think you can hugely simplify this down to:
if Date.StartOfMonth([AdmissionsMonth]) = Date.StartOfMonth(Date.AddMonths(Date.From(DateTime.LocalNow()), -1))
then "Last Month"
else [AdmissionsMonth]
Pete
Proud to be a Datanaut!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |