Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Change hierarchy level in matrix visualization

Hi!   I need to create a Matrix visual (or  a visual table looking that does the same thing) using 2 levels of hierarchy. This is the data:     And I need to display the total of all (that...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous , 

    Please refer to my pbix file to see if it helps you.

    Create a measure.

    Measure =
    VAR _value =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
                    && 'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
            )
        )
    VAR _NIKE =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
                    && 'Table'[City] = SELECTEDVALUE ( 'Table'[City] )
            )
        )
    VAR result =
        IF (
            HASONEVALUE ( 'Table'[City] )
                && MAX ( 'Table'[Company] ) = "NIKE",
            _NIKE,
            IF (
                HASONEVALUE ( 'Table'[City] )
                    && MAX ( 'Table'[Company] ) = "Adidas",
                _NIKE,
                SELECTEDVALUE ( 'Table'[Value] )
            )
        )
    VAR _a =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Label] = SELECTEDVALUE ( 'Table'[Label] )
                    && 'Table'[Company] = SELECTEDVALUE ( 'Table'[Company] )
            )
        )
    RETURN
        IF ( HASONEVALUE ( 'Table'[City] ), result, _a )
    

     

    If I have misunderstood your meaning, please provide more details with your desired output.

     

    Best Regards

    Community Support Team _ Polly

     

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