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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.