Forum Discussion

BOkungbure's avatar
BOkungbure
Regular Visitor
2 years ago
Solved

Matrix Calculation on 1st and 2nd Level

Hello Everyone,   I have a table that has data arranged into main sections and subsections as shown below. Main Section Sub Section Value Section A Sub Section 1 10 Section A Sub Sec...
  • Sahir_Maharaj's avatar
    2 years ago

    Hello BOkungbure,

     

    Can you please try this:

     

    1. Calculate the Maximum Total across all Sections

    Max Total Value = 
    MAXX(
        ALL('YourTableName'[Main Section]),
        SUMX(
            FILTER(
                'YourTableName',
                'YourTableName'[Main Section] = EARLIER('YourTableName'[Main Section])
            ),
            'YourTableName'[Value]
        )
    )

    2. Calculate the Ratio

    Ratio = 
    VAR MainSectionTotal = 
    SUMX(
        FILTER(
            'YourTableName',
            'YourTableName'[Main Section] = EARLIER('YourTableName'[Main Section])
        ),
        'YourTableName'[Value]
    )
    
    VAR CurrentValue = 
    IF(
        ISINSCOPE('YourTableName'[Sub Section]),
        SUM('YourTableName'[Value]),
        MainSectionTotal
    )
    
    RETURN
    DIVIDE(CurrentValue, [Max Total Value])

     

    Should you require any further assistance, feel free to reach out to me.

  • BOkungbure's avatar
    2 years ago

    Thanks Sahir,
    This solution was super helpful, ISINSCOPE was the missing piece