Hello @Tibbie,

Thank You for posting your query onto the Forum.

And you’re welcome. I’m glad that I was able to assist you on your previous query.

Now, coming back to this one. Let’s break this solution into two parts -

**Part 1: Getting Correct Sub-Totals of Price Index Unweighted (1) - Harsh**

This is one quite straight-forward. The reason why you got incorrect totals at the “**Competitor**” level is because you simply applied the measure at an entire level rather than only applying or considering it at an “**ARTICLE_ID**” level only.

So what actually happened here was it evaluated the “**Average**” results at all the levels rather than first summing it up at the “**Competitor**” and “**Market Name**” level and then dividing it by the number of rows of “**ARTICLE_ID**”.

To achieve the “**Average**” results at an individual level of “**ARTICLE_ID**” and to “**Sum**” them up at a “**Market Name**” and “**Competitor**” level and then divide them by the number of rows of “**ARTICLE_ID**”. Below is the measure alongwith the screenshot of the results provided for the reference -

```
Price Index Unweighted (1) - Harsh =
VAR _Condition_1 =
DIVIDE(
AVERAGE( PricesAndProducts[Our Price] ) ,
AVERAGE( PricesAndProducts[Competitor Price] ) ,
0 ) * 100
VAR _Condition_2 =
DIVIDE(
SUMX(
ADDCOLUMNS(
SUMMARIZE(
PricesAndProducts ,
PricesAndProducts[MarketName] ,
PricesAndProducts[Competitor] ,
PricesAndProducts[ARTICLE_ID] ,
"@Totals" ,
DIVIDE(
AVERAGE( PricesAndProducts[Our Price] ) ,
AVERAGE( PricesAndProducts[Competitor Price] ) ,
0 ) * 100 ) ,
"@Totals - Harsh" ,
IF( [@Totals] > 0 , [@Totals] , BLANK() ) ) ,
[@Totals - Harsh] ) ,
COUNTROWS( VALUES( PricesAndProducts[ARTICLE_ID] ) ) ,
0 )
VAR _Results =
SWITCH( TRUE() ,
ISINSCOPE( PricesAndProducts[Competitor] ) , _Condition_2 ,
_Condition_1 )
RETURN
_Results
```

So now, you’ll observe that the results which you were looking for “**90.6**” is correctly getting reflected. **Part One ends here.**

**Part 2: Getting Correct Sub-Totals of Price Index Weighted (1) - Harsh**

Now, this one was tricky. The reason being is, in the previous post, you considered your condition was like this -

**In my example i have “competitors” and “articles” so I would like to calculate the share of “competitors” by the grand total and then the “articles” within the competitors so they are the grand total.**

And that’s what actually was happening here in your second case. So when you used to calculate the proportion at an individual levels i.e. at an “**ARTICLE_ID**” level, it also used to calculate the proportions at a “**Market Name**” and “**Competitor**” level.

For example, the percentage or sales share of “**Competitor No. 3**” is “**5.4%**” and based on this figure, it used to calculate the figures accordingly.

Ideally, since you want to sum it up at a “**Market Name**” and “**Competitor**” levels that figure should have been “**100%**” i.e. consolidation of all the % sales share of “**ARTICLE_ID**” at their respective “**Competitor**” levels. And thereby, consolidation of each “**Competitor**” level at their “**Market Name**” level. And that’s how, you’ll actually be able to achieve the results. Below is the measure alongwith the screenshot of the results provided for the reference -

```
Price Index Weighted (1) - Harsh =
VAR _Condition_1 =
DIVIDE(
AVERAGE( PricesAndProducts[Our Price] ) ,
AVERAGE( PricesAndProducts[Competitor Price] ) ,
0 ) * 100 *
DIVIDE(
SUM( PricesAndProducts[Sales] ) ,
CALCULATE ( SUM( PricesAndProducts[Sales] ) ,
ALLSELECTED( PricesAndProducts[ARTICLE_ID] ) ) ,
0 )
VAR _Condition_2 =
SUMX(
ADDCOLUMNS(
SUMMARIZE(
PricesAndProducts ,
PricesAndProducts[MarketName] ,
PricesAndProducts[Competitor] ,
PricesAndProducts[ARTICLE_ID] ,
"@Totals" ,
DIVIDE(
AVERAGE( PricesAndProducts[Our Price] ) ,
AVERAGE( PricesAndProducts[Competitor Price] ) ,
0 ) * 100 *
DIVIDE(
SUM( PricesAndProducts[Sales] ) ,
CALCULATE ( SUM( PricesAndProducts[Sales] ) ,
ALLSELECTED( PricesAndProducts[ARTICLE_ID] ) ) ,
0 ) ) ,
"@Totals - Harsh" ,
IF( [@Totals] > 0 , [@Totals] , BLANK() ) ) ,
[@Totals - Harsh] )
VAR _Results =
SWITCH( TRUE() ,
ISINSCOPE( PricesAndProducts[ARTICLE_ID] ) , _Condition_1 ,
ISINSCOPE( PricesAndProducts[MarketName] ) || ISINSCOPE( PricesAndProducts[Competitor] ) , _Condition_2 ,
_Condition_2 )
RETURN
_Results
```

Now, after observing the above screenshot, you must be wondering that - “**Harsh, answer should have been “****89.9**” and not “**89.8**”.”

**So does that mean, is my measure incorrect? - Absolutely, not. I just an decimal issue.**

Once you round the figures upto 2 decimal places rather than 1, you’ll observe that numbers will start to get tallying out (**Note: There’s nothing that can be done to solve this type of decimal issue**). Below is the screenshot of the final results provided for the reference -

After the lengthy explanation, I guess you’ll also require a PBIX file so I’m attaching the working of the PBIX file for the reference purposes.

Hoping you find this useful and meets your requirements that you’ve been looking for.

Thanks and Warm Regards,

Harsh

PricingDashboard - Harsh.pbix (782.6 KB)