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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Ereon
Regular Visitor

DAX Measure to divide each row by a Total Row within the same table. There are three total rows.

I have Circana/IRI sales data coming in through a SQL connection joined to 4 identifier tables (Geographies, Product ID, Reporting Periods, and Category).  The main Sales Table has three rows for Total US sales (RMA, CRMA MULO+, and CRMA MULO+ Conv).  Depending on the table/filters, I need to divide a Geographies sales by the Total US sales, related to which Geography type.  All Geographies have the same 3 Category break outs as Total US.

I need to calculate Share of a Geography by Reporting Period, by Product, by Category using the correct Total US Geography and match to the same RMA, CRMA - MULO+, or CRMA - MULO+ Conv.

Share = (Current Geography ID) / (Total US)

Sales Table

Reporting Period IDGeography IDProduct IDCategory ID$ SalesLY $ SalesShare
1511234562000019000100%
1521234563500034000100%
1531234564000039000100%
1541234565000450025.0%
1551234565500500015.7%
1561234566000650015.0%
1571234563500300017.5%
1581234564200440012%
1591234565200550013%

(note that there are several different Reporting Periods, Product IDs, and Category IDs for each Geography ID)

Geography Table

Geography IDGeography_NameRMA_CRMA_MULTI
1Total US - FoodRMA
2Total US - MULO+CRMA - MULO+
3Total US - MULI+ ConvCRMA - MULO+
4Atlanta - CRMA - FoodCRMA
5Atlanta - CRMA - MULO+CRMA - MULO+
6Atlanta - CRMA - MULO+ ConvCRMA - MULO+
7Atlanta - RMA - FoodRMA
8Central - CRMA - FoodCRMA
9

Central - CRMA - MULO+

CRMA - MULO+
10Central - CRMA - MULO+ ConvCRMA - MULO+
11Central - RMA - FoodRMA


Any help is greatly appreciated.

 

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@Ereon First, you need to create a measure that calculates the Total US sales for each combination of Reporting Period, Product, and Category.

DAX
TotalUSSales =
CALCULATE(
SUM(SalesTable[$ Sales]),
SalesTable[Geography ID] IN {1, 2, 3}
)

 

Next, create a measure that calculates the sales for the current Geography ID.

GeographySales = SUM(SalesTable[$ Sales])

 

Finally, create a measure to calculate the share of the current Geography sales relative to the Total US sales.

DAX
Share =
DIVIDE(
[GeographySales],
[TotalUSSales],
0
)

 

Ensure that your report or visual applies the necessary filters for Reporting Period, Product, and Category to correctly calculate the share for each combination.

Use the Geography Table to map each Geography ID to its corresponding Total US Geography type (RMA, CRMA - MULO+, CRMA - MULO+ Conv) to ensure the correct Total US sales are used in the calculation.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

Hi @Ereon , apologies, that was a typo on my end. Please try the following:

Share = 
DIVIDE(
    SUM(Sales[$ Sales]),
    CALCULATE(
        SUM(Sales[$ Sales]),
        REMOVEFILTERS(Geography),
        TREATAS(
            VALUES(Geography[RMA_CRMA_MULTI]),
            Geography[RMA_CRMA_MULTI]
        ),
        FILTER(
            ALL(Geography),
            SEARCH("Total US", Geography[Geography_Name], 1, 0) > 0
        )
    )
)

View solution in original post

7 REPLIES 7
SamsonTruong
Solution Supplier
Solution Supplier

Hi @Ereon ,

Below is a DAX measure that can be applied to your use case:

Share = 
DIVIDE(
    SUM(Sales[$ Sales]),
    CALCULATE(
        SUM(Sales[$ Sales]),
        REMOVEFILTERS(Geography),
        TREATAS(
            VALUES(Geography[RMA_CRMA_MULTI]),
            Geography[RMA_CRMA_MULTI]
        ),
        FILTER(
            ALL(Geography),
            SEARCH("Total US", Geography[Geography_Name], 1, 0) > 0
        )
    )
)


Please let me know if this works as intended.

If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

Thanks,

Samson

Get this error when attempting:

Ereon_0-1748618126697.png

 

Hi @Ereon , apologies, that was a typo on my end. Please try the following:

Share = 
DIVIDE(
    SUM(Sales[$ Sales]),
    CALCULATE(
        SUM(Sales[$ Sales]),
        REMOVEFILTERS(Geography),
        TREATAS(
            VALUES(Geography[RMA_CRMA_MULTI]),
            Geography[RMA_CRMA_MULTI]
        ),
        FILTER(
            ALL(Geography),
            SEARCH("Total US", Geography[Geography_Name], 1, 0) > 0
        )
    )
)

Perfect, that worked!  I was looking for it all in one measure just to reduce the amount of Measures I have.

@Ereon Awesome to hear it worked!

bhanu_gautam
Super User
Super User

@Ereon First, you need to create a measure that calculates the Total US sales for each combination of Reporting Period, Product, and Category.

DAX
TotalUSSales =
CALCULATE(
SUM(SalesTable[$ Sales]),
SalesTable[Geography ID] IN {1, 2, 3}
)

 

Next, create a measure that calculates the sales for the current Geography ID.

GeographySales = SUM(SalesTable[$ Sales])

 

Finally, create a measure to calculate the share of the current Geography sales relative to the Total US sales.

DAX
Share =
DIVIDE(
[GeographySales],
[TotalUSSales],
0
)

 

Ensure that your report or visual applies the necessary filters for Reporting Period, Product, and Category to correctly calculate the share for each combination.

Use the Geography Table to map each Geography ID to its corresponding Total US Geography type (RMA, CRMA - MULO+, CRMA - MULO+ Conv) to ensure the correct Total US sales are used in the calculation.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you @bhanu_gautam.  I forgot that simple lesson I learned when making another dashboard!

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.