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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gdaniel
Frequent Visitor

Show 6 months of data, total the rest

Hello, 

I need to create a Matrix report that show 6 months of data, then totals everything beyond 6 months.  

I have sucessfully created a calculated column that does this.  

 

_MonthYear =
IF('Calendar'[Date] >= EOMONTH(TODAY(), 6), "Beyond 6 Months"  'Calendar'[MonthYear])
 
It works, but displays the months in alphabetical order, not chronological.  
 
gdaniel_0-1741807404328.png

 

I need to figure out either 1) how to sort the _MonthYear column chronologically, or 2) how to hide columns greater than 6 months out but still keep the Total column.  

 

The error I get when trying to sort the _MonthYear column is this:

 

gdaniel_1-1741807578494.png

Appreciate any help!

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

To sort chronologically, you need to create a new integer column. This could be something like:

Month Sort Column = SWITCH('Calendar'[MonthYear], "Beyond 6 Months", 9999999, FORMAT('Calendar'[MonthYear], "yyyymm") // e.g. Apr-2025 should give you 202504

vicky__0-1741814805480.png

then select your original Month-Year column and sort using the above.

 

Otherwise, you could try something like:

Table Measure = IF(HASONEVALUE(Calendar[MonthYear]), [Your normal calculation], [Your calculation for the total])

View solution in original post

4 REPLIES 4
techies
Super User
Super User

Hi @gdaniel please try this

 

 

In Power Query, add an Index Column to your Calendar table and name it _MonthYearIndex.
In Data View, select _MonthYear and sort it by _MonthYearIndex.

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
vicky_
Super User
Super User

To sort chronologically, you need to create a new integer column. This could be something like:

Month Sort Column = SWITCH('Calendar'[MonthYear], "Beyond 6 Months", 9999999, FORMAT('Calendar'[MonthYear], "yyyymm") // e.g. Apr-2025 should give you 202504

vicky__0-1741814805480.png

then select your original Month-Year column and sort using the above.

 

Otherwise, you could try something like:

Table Measure = IF(HASONEVALUE(Calendar[MonthYear]), [Your normal calculation], [Your calculation for the total])

Thanks @vicky_ ,  I created a column like this, and it works to create the correct data in the column:  

 

_Sort2 = IF(
    'Calendar'[Date] >= EOMONTH(TODAY(), 6), "999999",
        FORMAT( 'Calendar'[Date], "YYYYMM"))
 
gdaniel_0-1741878878474.png

However, when I try to sort my _MonthYear column with this new _Sort2 column, I get a very unhelpful error message  😞 

gdaniel_1-1741878952351.png

I will keep working on this, and post a solution if I find one.

Update - the sort column solution above worked!  I researched the validation error message I received, and was able to resolve it by doing this:  

Verify whether a program is causing the issue by closing Power BI Desktop, opening Windows Settings > About > Advanced system settings and selecting Environment Variables. Select New under User variables and add variable name WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS with the value --disable-features=RendererCodeIntegrity.

Thanks again @vicky_ 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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