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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Aggregation of row level measure

Hi,

I have an interesting issue I cannot resolve in Power BI.

 

I have a measure that is a row level calculation; as determined (for each unique sub-type of product, for each product)

This computes a value for each row and in theory it should then sum up to 100%. It doesn't for reasons which are not relevant. However I would like to normalise this by dividing the measure e.g. 1.6% by the sum of the column e.g. 97%.

 

Unfortunately PowerBI is not as intuitive as to how this can be done. I cannot appear to get it to work despite using allexcept and other methods.

 

Basically I need to create a column that is a fixed value i.e. the 97%. I thought about just dividng by 97% but each region may have a different subtotal.

 

The measure Sales Value (%) is the row level calculation. This is the table I have today

RegionProduct TypeProduct Sub-typeProductSales (%)Value NormaliserSales Value (%)
EMEAPrimarySus-371291.58%11.58%
EMEAPrimaryKno-456983.07%13.07%
EMEAPrimaryEff-226591.52%11.52%
EMEAPrimaryKno-456981.66%0.60.99%
EMEASecondarySaf-727301.66%0.40.66%
EMEAPrimaryQua-667451.71%0.61.03%
EMEASecondarySus-371291.71%0.40.69%
EMEASecondaryHea-991521.75%0.20.35%

 

I require a Table to look like this:

Normalised Sales Value (%) would be the Sales Value (%) divided by the Sum of Sales Value (%)

RegionProduct TypeProduct Sub-typeProductSales (%)Value NormaliserSales Value (%)Sum of Sales Value (%)Normalised Sales Value (%)
EMEAPrimarySus-371291.58%11.58%97%1.63%
EMEAPrimaryKno-456983.07%13.07%97%3.16%
EMEAPrimaryEff-226591.52%11.52%97%1.57%
EMEAPrimaryKno-456981.66%0.60.99%97%1.02%
EMEASecondarySaf-727301.66%0.40.66%97%0.68%
EMEAPrimaryQua-667451.71%0.61.03%97%1.06%
EMEASecondarySus-371291.71%0.40.69%97%0.71%
EMEASecondaryHea-991521.75%0.20.35%97%0.36%

 

Additional details:

My 'Sales Value (%) measure is as follows:

 
Sales Value (%) = SUMX(SUMMARIZE('Sales','Sales'[Product Sub-type],'Sales'[Product],"Subtotal",SUM('Sales'[Sales (%)])*SUM('Product'[Value Normaliser])),[Subtotal])
 
Region is pulling from another table 'Master', Value Normaliser from 'Product' and everything else from 'Sales'.
 
Thank you in advance.

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

you're on the right path with SUMX.  But you need to do that for both the "row" and for the entire filter context (ALLSELECTED)

 

By the way, "row" is an ambiguous term.  You DO have rows in your source tables. Measures do NOT apply to them (calculated columns do).  You MAY have "rows" in some visuals, but try to think of these not as rows but as collections of filters (ie filter context). Measures DO apply to these. 

View solution in original post

4 REPLIES 4

Ok, so I now have a new problem due to requirements.

 

The end user wants to see the split by Product Type.

When I use the following formula each product type split on the chart adds up to 100%; thus it is a percentage of the total data for each product type instead of overall.

Sales Value (%) Total = CALCULATE([Sales Value (%)]ALLSELECTED())

Any ideas?

 

 

 

You can use SELECTEDVALUE() to figure out which ProductType you are currently looking at in each cell of your visual.  But that won't work for the totals. There you need to collect all possible product types, and then compute the result across them.  Incidentally that approach will also work for individual cells, ovbiating the need for SELECTEDVALUE.  The saying goes "Think like the Grand Total".

Noted.

I have created two new fields:
Sales Value (%) Total = CALCULATE([Sales Value (%)], ALLSELECTED())

Sales Value Nm = 'Sales'[Sales Value (%)] / 'Sales'[Sales Value (%) Total]

 

Sales Value (%) gives me the fixed total, as per filter

Sales Value Nm gives me the normalised row level calculation

 

Thank you

lbendlin
Super User
Super User

you're on the right path with SUMX.  But you need to do that for both the "row" and for the entire filter context (ALLSELECTED)

 

By the way, "row" is an ambiguous term.  You DO have rows in your source tables. Measures do NOT apply to them (calculated columns do).  You MAY have "rows" in some visuals, but try to think of these not as rows but as collections of filters (ie filter context). Measures DO apply to these. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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