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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Maciek048
New Member

Month number

Hello, I need to have in PowerBI a column which will display number of month in callendar.

At this moment I have an Callendar table created by 

CALENDAR = CALENDAR(DATE(2018.,1.,1),EOMONTH(Today(),0)) function.
Maciek048_0-1675090507423.png

 

Now I need a cloumn which will display number of month started from courrent month, for eg.:
 
January 2023 (this month) - 0
December 2022 - 1
November 2022 - 2
October 2022 - 3
September 2022 - 4
etc.
 
It is crucial to have data alligned with every future months and updated with past. 
Every next current month will get "0", and previous "1", and next prev. one "2" etc. till end of created callendar table (the numbers are not from 1-12 range).
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Maciek048 

try like:

NewColumn = 
DATEDIFF([DATE], TODAY(), MONTH)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Maciek048 

please try

Number of Month =
RANKX ( 'CALENDAR', FORMAT ( 'CALENDAR'[Date], "YYYYMM" ),, Asc, DENSE ) - 1

FreemanZ
Super User
Super User

hi @Maciek048 

try like:

NewColumn = 
DATEDIFF([DATE], TODAY(), MONTH)

Thanks it works. I needed only to add "-" before statement to achieve exactly what I want.

Column = -(DATEDIFF(TODAY(), [DATE], MONTH))

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.