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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Syndicate_Admin
Administrator
Administrator

List a Calendar Table

Dear I have a calendar table that is dynamic, ranging from a minimum date (1/1/2020) to a maximum date (30/6/2022), for example I put it in hard.

What I want is to add a correlative to the beginning "Nro", in such a way that all the dates of the last month i.e. June 2022, let be 1, all the dates of the month of May 2022 would be 2, all the dates of April 2022 would be 3 and so on.

The table for the calendar I'm using is:

Thanks in advance for your help

Calendar =
WHERE Date = CALENDAR(
DATE( 2020, 1, 1) ,
DATE (2022, 6, 30)
)
return SELECTCOLUMNS
(
Date,
"Date", [Date],
"Year" , YEAR ( [Date] ),
"My", UPPER ( FORMAT ( [Date], "MMM") ),
"MesNro", ( FORMAT ([Date], "MM" ) ),
"Day", ( FORMAT( [Date], "DD" ) ),
"QuarterNro", ROUNDUP(MONTH([Date]) / 3, 0 ),
"Quarter" , "Q" & ROUNDUP( MONTH( [Date] ) / 3, 0 ),
"AñoMes", YEAR ( [Date] ) * 100 + MONTH ([Date]),
"MesAño", UPPER(FORMAT ([Date], "MMM" ) ) & "-" & RIGHT (YEAR ( [Date] ),4),
"AñoQ", YEAR ( [Date]) * 100 + ROUNDUP( MONTH( [Date] ) / 3, 0 ),
"QAño" , "Q" & ROUNDUP( MONTH( [Date] ) / 3, 0 ) & "- " & RIGHT (YEAR ( [Date] ),4)
)
1 ACCEPTED SOLUTION
Hariharan_R
Solution Sage
Solution Sage

Hi @Syndicate_Admin 

Follow the below steps.

1. Create a new DAX table using below script.

 

Rank = 
VAR _Date = CALENDAR(
DATE( 2020, 1, 1) ,
DATE (2022, 6, 30)
)
return DISTINCT(SELECTCOLUMNS
(
_Date,

"MesAño", UPPER(FORMAT ([Date], "MMM" ) ) & "-" & RIGHT (YEAR ( [Date] ),4),
"AñoMes", YEAR ( [Date] ) * 100 + MONTH ([Date])
))

 

2. Add calculated column on the Rank table

 

Nro = RANKX('Rank','Rank'[AñoMes],,DESC)

 

Hariharan_R_0-1657631121663.png

 

3. Create a relationship

Hariharan_R_1-1657631154574.png

4. Create a calculated column in your date table 

Hariharan_R_2-1657631201006.png

Thanks

Hari

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


My Blog :: YouTube Channel :: My Linkedin


View solution in original post

2 REPLIES 2
Hariharan_R
Solution Sage
Solution Sage

Hi @Syndicate_Admin 

Follow the below steps.

1. Create a new DAX table using below script.

 

Rank = 
VAR _Date = CALENDAR(
DATE( 2020, 1, 1) ,
DATE (2022, 6, 30)
)
return DISTINCT(SELECTCOLUMNS
(
_Date,

"MesAño", UPPER(FORMAT ([Date], "MMM" ) ) & "-" & RIGHT (YEAR ( [Date] ),4),
"AñoMes", YEAR ( [Date] ) * 100 + MONTH ([Date])
))

 

2. Add calculated column on the Rank table

 

Nro = RANKX('Rank','Rank'[AñoMes],,DESC)

 

Hariharan_R_0-1657631121663.png

 

3. Create a relationship

Hariharan_R_1-1657631154574.png

4. Create a calculated column in your date table 

Hariharan_R_2-1657631201006.png

Thanks

Hari

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


My Blog :: YouTube Channel :: My Linkedin


Thank you very much, you helped me a lot.

Best regards

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.