Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello i have a dataset like the one below, and i'm trying to aggregate the months and respective sales, as well as formatting the months, as seen in the second table. I can do this with reference tables or group function, but i'm trying to do this with DAX.
Can someone please help me with the DAX? Thank you
| Month | Sales |
| July 01 2003 | 4 |
| July 02 2003 | 5 |
| July 03 2003 | 8 |
| August 07 2003 | 11 |
| August 09 2003 | 6 |
| August 12 2003 | 9 |
| September 07 2003 | 8 |
| September 10 2003 | 5 |
| Month | Sales |
| Jul 03 | 17 |
| Aug 03 | 26 |
| Sep 03 | 13 |
Solved! Go to Solution.
Hi @Antonio195754 ,
The approach depends on whether your month column is actually a date or a text.
If a date:
Month2 =
FORMAT ( 'Table'[Month], "mmm yy" )Sort =
FORMAT ( 'Table'[Month], "yyyymm" )
If a text:
Month2 =
FORMAT ( DATEVALUE ( 'Table'[Month2] ), "mmm yy" )
Sort =
FORMAT ( DATEVALUE ( 'Table'[Month2] ), "yyyymm" )
Since either of those formula will return a text string, the values will be sorted alphabetically thus the need for a custom column sort.
Hi @Antonio195754 ,
The approach depends on whether your month column is actually a date or a text.
If a date:
Month2 =
FORMAT ( 'Table'[Month], "mmm yy" )Sort =
FORMAT ( 'Table'[Month], "yyyymm" )
If a text:
Month2 =
FORMAT ( DATEVALUE ( 'Table'[Month2] ), "mmm yy" )
Sort =
FORMAT ( DATEVALUE ( 'Table'[Month2] ), "yyyymm" )
Since either of those formula will return a text string, the values will be sorted alphabetically thus the need for a custom column sort.
That was so simple. It worked like a charm. Created both columns and then sorted off the sort column, aggregated my months with the sales rolling up to it. Thank you!
The date field was in date format, so went with your first suggestion.
Hi,
Ensure that the Month column has proper right aligned dates. Create a Calendar Table with calculated column formulas for Year, Month name and Month number. Sort the Month name by the Month number. To your visual, drag Year and Month name from the Calendar Table. Write this measure
Total = sum(Data[Sales])
Hope this helps.
Hey @Ashish_Mathur yes i did it that way originally and it worked, but to improve my DAX skills, i'm trying to accomplish it that way. Any suggestions? The date field comes in as date format.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.