Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ArchStanton
Power Participant
Power Participant

Offset Month Calculated Column

Hi,

 

I have a column named 'Month' which just has the dates of the 1st day of each month (see below)

 

ArchStanton_0-1666865834517.png

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

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@ArchStanton,

 

Try this calculated column in the table DimDate:

 

Offset Month = 
VAR vToday =
    TODAY ()
VAR vResult =
    DATEDIFF ( vToday, DimDate[Date], MONTH ) + 1
RETURN
    vResult

 

DataInsights_0-1666875918707.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
DataInsights
Super User
Super User

@ArchStanton,

 

Try this calculated column in the table DimDate:

 

Offset Month = 
VAR vToday =
    TODAY ()
VAR vResult =
    DATEDIFF ( vToday, DimDate[Date], MONTH ) + 1
RETURN
    vResult

 

DataInsights_0-1666875918707.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

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!

 

tsolberg_0-1673366389881.png

 

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.

 

Anonymous
Not applicable

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!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.