Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
I have a column named 'Month' which just has the dates of the 1st day of each month (see below)
The MAX month as you can see is Sep 2022.
I would like to create a calculated column 'Offset Month' whereby the Max month will always be zero and the previous month -1 and then -2 and so on. The logic sounds very simple but I'm still learning DAX and not quite there yet, can anyone help?
Thanks
Solved! Go to Solution.
Try this calculated column in the table DimDate:
Offset Month =
VAR vToday =
TODAY ()
VAR vResult =
DATEDIFF ( vToday, DimDate[Date], MONTH ) + 1
RETURN
vResult
Proud to be a Super User!
Try this calculated column in the table DimDate:
Offset Month =
VAR vToday =
TODAY ()
VAR vResult =
DATEDIFF ( vToday, DimDate[Date], MONTH ) + 1
RETURN
vResult
Proud to be a Super User!
Hi there,
I am trying to accomplish this same thing, but I am receiving the following error. Any idea why this wouldn't be working for me?
Thanks!
The solution was in DAX so its meant to be used in the Data Model, I can see you're in Query Editor and that uses M language, thats a different environment.
Cancel that and instead create a calculated column using the same code in your table within the datamodel instead.
Ah hah. That did the trick. I am still new to Power BI, so still much to learn. Thank you!
No problem
Perfect, thats exactly what I need!
Many thanks!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
142 | |
71 | |
64 | |
52 | |
50 |
User | Count |
---|---|
208 | |
91 | |
62 | |
59 | |
56 |