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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
edwinb
Frequent Visitor

Matrix Row Subtotal Random Text

I'm using the Matrix visual with a text description. When I expand the visual +/- you can see the correct description on the actual row, but it shows a random description in the subtotal header from a sub-row below. The description is set to show the first description, but it doesn't always do this. Is there anyway to fix this behavior?

 

Thanks! 

Annotation 2020-05-26 153442.jpg

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @edwinb ,

 

The reason for this issue is the default alphabetical order.

Please try the following steps:

1.Add an index column to the query editor.

2.Get the first "description" based on the index column

Measure =
VAR MIN_INDEX =
    CALCULATE (
        MIN ( 'Table (2)'[Index] ),
        ALLEXCEPT ( 'Table (2)', 'Table (2)'[level1] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Table (2)'[level2] ),
        MAX ( 'Table (2)'[Description] ),
        CALCULATE (
            MAX ( 'Table (2)'[Description] ),
            FILTER ( 'Table (2)', 'Table (2)'[Index] = MIN_INDEX )
        )
    )

test_ Matrix Row Subtotal Random Text.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @edwinb ,

 

The reason for this issue is the default alphabetical order.

Please try the following steps:

1.Add an index column to the query editor.

2.Get the first "description" based on the index column

Measure =
VAR MIN_INDEX =
    CALCULATE (
        MIN ( 'Table (2)'[Index] ),
        ALLEXCEPT ( 'Table (2)', 'Table (2)'[level1] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Table (2)'[level2] ),
        MAX ( 'Table (2)'[Description] ),
        CALCULATE (
            MAX ( 'Table (2)'[Description] ),
            FILTER ( 'Table (2)', 'Table (2)'[Index] = MIN_INDEX )
        )
    )

test_ Matrix Row Subtotal Random Text.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@V-lianl-msft 

 

I keep trying to rework my power bi file with no luck. I'm not sure why I can't get the subtotal rows to show the correct text descriptions? Reguardless of what level is expanded, I'm trying to get the description to show correctly. It does so when there is only one option, but not for subtotals with more than one desciption. I'll keep trying, but if you have time to look at it, I provided a box link to the pbix file above. Thanks

Measure Description = 
VAR MIN_INDEX =
    CALCULATE (
        MIN ( 'Table'[Index] ),
        ALLEXCEPT ( 'Table', 'Table'[L1] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Table'[L3] ),
        MAX ( 'Table'[Description] ),
        CALCULATE (
            MAX ( 'Table'[Description] ),
            FILTER ( 'Table', 'Table'[Index] = MIN_INDEX )
        )
    )

 

 Annotation 2020-06-04 103136.jpg

edwinb
Frequent Visitor

@V-lianl-msft Thanks for pointing me in the right direction.

Here is what I finally got working. I had to simplify the variable to work on the different levels of hierarchy

Measure Description = 
VAR MIN_INDEX =
            MIN ( 'Assembly Codes & Unit Costs'[Index] )
RETURN
    IF (
        ISINSCOPE ( 'Assembly Codes & Unit Costs'[L4] ),
        MAX ( 'Assembly Codes & Unit Costs'[Description] ),
        CALCULATE (
            MAX ( 'Assembly Codes & Unit Costs'[Description] ),
            FILTER ( 'Assembly Codes & Unit Costs', 'Assembly Codes & Unit Costs'[Index] = MIN_INDEX )
        )
    )

 Annotation 2020-06-05 171926.jpg

Greg_Deckler
Super User
Super User

@edwinb  Well, it is not random. This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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