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
clp7285
Frequent Visitor

Need help with DAX expression to create a Quarter and Year calculated column

I've already created a "Quarter" calculated column to display Q1, Q2, Q3, Q4 by doing some research online. Quarter = FORMAT('Date'[Date],"\Qq")clp7285_0-1650918157834.png

 

I have a 'Date" table and 'Date' field, and also a 'Year' field. 

Date =
ADDCOLUMNS (FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [Date] ) >= 2019, YEAR ( [Date] ) <= TODAY() )
),
"Year", YEAR ( [Date] ),
 
For a matrix header I need to have the headers as Q1 2020, Q2 2020, Q3 2020, Q4 2020, Q1 2021, Q2 2021, Q3 2021, Q4 2021, Q1 2022, Q1 2022. clp7285_0-1650919117537.png

 

I'm trying to create a calculated column to combine both "\Qq" space then "YYYY" but I can't seem to get it to work. Would I need to use a different DAX function than FORMAT? I'm having a hard time figuring out the correct DAX syntax. Any help would be appreciated.
 
Christine
1 ACCEPTED SOLUTION

Thank you. The QuarterSort, Sort by Column worked.

View solution in original post

6 REPLIES 6
Whitewater100
Solution Sage
Solution Sage

Sorry:

Try this..

Q = "Q" & FORMAT(DATES[Date],"Q YYYY")
This will work and show Q1 2022   etc...

Whitewater100,

I couldn't get DATES to select so I needed to alter it a bit to 'Date' instead of DATES but it worked! Thanks!

Quarter and Year = "Q" & FORMAT('Date'[Date], "Q YYYY").  
The only problem is that it is displaying Q1 2020, then Q1 2021, then Q1 2022. It puts all the Q1's together then the Q2's etc. I want it to be chronological Q1 2020, Q2 2020 so sorted by year and then Q1, Q2, etc. - all the 2020 quarters show before moving into 2021.  When I click on the thee horizontal dots 'Sort by" Year is not listed as an option. Not sure how to get this to be in the order I need. Any suggestions?clp7285_0-1650922040217.png

 

Hi:

Yes, your Date table is named Date and mine is Dates.

To answer your question.

Please have another CC (this will be to sort y)

QuarterSort = FORMAT(DATE[Date], "YYYYQ")
 
Now click on your Q1 2022 column (the one we did earlier) and choose "Sort by Column" at top. Now choose this new column to sort the first one.
If fine, can you mark as accepted solution? Thanks..
Here's a image to help demo.
Whitewater100_0-1650929374373.png

 

 

Thank you. The QuarterSort, Sort by Column worked.

Hi:

That's great! Can you mark my answer as accepted solution? Have a nice day. 

Whitewater100
Solution Sage
Solution Sage

Hi Christine:

You can add a CC to your dates table

Q# 

= "Q" & FORMAT(DATES[Date],"Q")
I hope this helps!

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors