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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
brycewps
Regular Visitor

Measure to calculate the total of a column to use as a denominator in a measure

Hi all,

 

The measure I want to create calculates the % share each product makes up an individual retail channel and the desired output is a matrix visualization.  My problem is writing a formula the sums each retailer's total to create the denominator in the % share calc.  

 

I tried 

TY Sales (Static Total) (LW) = calculate(calculate(sum('Channel Sales'[SALES_$]),ALLSELECTED()),'Channel Sales'[Timing]="LW") but it sums total sales.  It works great until I add retailer to the columns in the matrix and then % share is based off the total of all retailers rather than the individual retailer.  I could expand the formula to filter on each retailer, but that requires 3 formulas and will create blanks in my matrix.  Hoping someone has an easy solve.  Thank you.

 

Data    
WeekTimingProductRetailerSales_$
19LWAWalmart5
19LWAAmazon10
19LWAWalmart5
19LWBWalmart10
19LWBAmazon10
19LWBTarget20
19LWBAmazon10
19LWCWalmart5
19LWCAmazon5
19LWCWalmart10
19LWCTarget20
19LWCTarget20

 

Desired output in matrix visualization:

Rows: product

Columns: retailer

Values: Sales_$ (LW) and % of Retailer

Current Output        Desired Output       
ProductAmazon% of RetailerTarget% of RetailerWalmart% of RetailerGrand Total% of Retailer ProductAmazon% of RetailerTarget% of RetailerWalmart% of RetailerGrand Total% of Retailer
A107.7% 0.0%107.7%2015.4% A1028.6% 0.0%1028.6%2015.4%
B2015.4%2015.4%107.7%5038.5% B2057.1%2033.3%1028.6%5038.5%
C53.8%4030.8%1511.5%6046.2% C514.3%4066.7%1542.9%6046.2%
Total3527%6046%3527%130100% Total35100%60100%35100%130100%

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @brycewps ,

 

Please try:

% of Retailer = DIVIDE(SUM('Channel Sales'[Sales_$]),CALCULATE(SUM('Channel Sales'[Sales_$]),ALLEXCEPT('Channel Sales','Channel Sales'[Retailer])))

Final output:

vjianbolimsft_0-1666165198725.png

Best Regards,

Jianbo Li

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

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @brycewps ,

 

Please try:

% of Retailer = DIVIDE(SUM('Channel Sales'[Sales_$]),CALCULATE(SUM('Channel Sales'[Sales_$]),ALLEXCEPT('Channel Sales','Channel Sales'[Retailer])))

Final output:

vjianbolimsft_0-1666165198725.png

Best Regards,

Jianbo Li

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

Shaurya
Memorable Member
Memorable Member

Hi @brycewps,

 

You can use the following formula to create the totals column based on Product and Retailer:

 

Product Total = SUMX('Table',IF('Table'[Product]=EARLIER('Table'[Product]),'Table'[Sales_$],0))

 

Retailer Total = SUMX('Table',IF('Table'[Retailer]=EARLIER('Table'[Retailer]),'Table'[Sales_$],0))

 

Screenshot 2022-10-08 001636.jpg

 

Hope this helps you in doing the rest. @ me more know if you need further help.

 

Did I answer your question? Mark this post as a solution if I did!

Hi @Shaurya - is it possible to use this in a DAX formula/measure?  My dataset is a bit more complex then the example I provided and I'm hoping to avoid bogging down the daily refreshes.  I attempted to input your formula as a DAX measure but received "earlier/earliest refers to an earlier row context which doesn't exist".

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors