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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

DAX Calendar - Grouping

Hi,

 

I am using the DAX calendar function as below:

 

CALENDAR (
    DATE ( 2019, 1, 1 ), 
    DATE ( 2019, 12, 31 )
)

 and this is working exactly as hoped as I can use it to total my data into months for the year.

 

However I have records that are pre 01/01/2019 and I want to show them as pre the calendar start date so I would have something like below:

 

Screen Shot 2019-06-03 at 17.25.35.png

 

Is there any additonal code i can add to my calendar to group anything pre 2019?

 

Any advice appreciated

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous you need to add following columns in your date table

 

Month = 
IF( YEAR( Calendar[Date] ) < 2019, 
"Pre 2019", 
FORMAT( Calendar[Date], "MMM-YY" ) 
)

add another column to sort the month

Month Sort = IF( YEAR( Calendar[Date] ) < 2019, "2019-00", FORMAT( Calendar[Date], "YYYY-MM" ) )

Select Month column and goto modelling tab, select sort by column and choose Month Sort

 

Now on matrix visual, put Month column and your value column on values and you will achieve the result.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@Anonymous you need to add following columns in your date table

 

Month = 
IF( YEAR( Calendar[Date] ) < 2019, 
"Pre 2019", 
FORMAT( Calendar[Date], "MMM-YY" ) 
)

add another column to sort the month

Month Sort = IF( YEAR( Calendar[Date] ) < 2019, "2019-00", FORMAT( Calendar[Date], "YYYY-MM" ) )

Select Month column and goto modelling tab, select sort by column and choose Month Sort

 

Now on matrix visual, put Month column and your value column on values and you will achieve the result.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k Worked a treat!  Thanks for the clear explanantion!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 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.