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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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