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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
BOkungbure
Regular Visitor

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 SectionSub SectionValue
Section ASub Section 110
Section ASub Section 29
Section ASub Section 321
Section BSub Section 122
Section BSub Section 275

 

I want create and measure that will show the ratio of the total value of each main section as well as the ratio of its subsections compared to the highest total across all other sections when expanded in a matrix visual.

 

So far, my measure only shows the ratio of the main section total compared to the maximum total in that table,

how do I ensure that when I expand to the subsections under their parent sections, the ratio calculation persists for each individual value of the subsections.

2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

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.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

BOkungbure
Regular Visitor

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

View solution in original post

2 REPLIES 2
BOkungbure
Regular Visitor

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

Sahir_Maharaj
Super User
Super User

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.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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