cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## Price gap calculation - All manufacturers vs. Specified manufacturer

Good day,

I'm busy with a price gap calculation using one manufacturer as the base and all other manufacturers average price compared to that specified manufacturer. Basically I need to get the average price difference of all manufacturers to the average price for manufacturer A i.e A-B, A-C, A-D etc. See below table as example of what is required.

 Bakery (All) Customer Group (All) Row Labels AVR Price Price Gap A 16.13 B 9.83 6.29 C 14.76 1.37 D 15.42 0.71 E 10.46 5.67 F 10.87 5.26 G 10.67 5.46 H 9.99 6.13 I 10.63 5.50 J 8.04 8.08 K 7.99 8.13 L 12.31 3.82 M 8.47 7.65 N 14.46 1.67 O 14.05 2.08 P 12.48 3.65 Q 11.75 4.38 R 10.56 5.57 S 10.64 5.48

The statement I'm using is as follow but I'm not getting the desired result:

``````gap test =
CALCULATE (
AVERAGE ( 'Pricing - GT (2)'[AVR Price] ),
FILTER ( 'Pricing - GT (2)', 'Pricing - GT (2)'[Manufacturer] = "Albany" )
)
- CALCULATE (
AVERAGE ( 'Pricing - GT (2)'[AVR Price] ),
ALL ( 'Pricing - GT (2)'[Manufacturer] )
)``````

Below is a sample of the table I use, table is linked only to a manufacturer sort order and a date tables:

Please can you assist me with this statment to be able to calculate a price gap as per the above?

Much appreciated,

Neville

4 REPLIES 4
Solution Sage

Hey,

If manufacturer A is equal to 'Albany', you can use this code:

``````gap test =
VAR _ManufacturerA =
CALCULATE (
AVERAGE ( 'Pricing - GT (2)'[AVR Price] ),
'Pricing - GT (2)'[Manufacturer] = "Albany"
)
VAR _CurrentManufacturer =
AVERAGE ( 'Pricing - GT (2)'[AVR Price] )
RETURN
_ManufacturerA - _CurrentManufacturer``````

Frequent Visitor

Hi Barthel,

Thank you for the expression, it works perfectly. I'm using this expression on another table with the same data but more to it, but it then just gives me the average pricing of each manufacturer as a negative price. How does additional fields effect the expression. What I don't have is the AVR Price column in the new table, but tried AVERAGE(Price) when pulling price on the grid. See sample table below. Would the expression also change if I use page filters for certain fields on the dashboard?

Regards,

Neville

Community Support

Hi @NevilleDuToit,

These aggregation functions should be effective based on current row contents, if you change the filter effects, they will also re-calculate the results.
Row Context and Filter Context in DAX - SQLBI

If you mean to calculate with multiple aggregations, you can take a look at Greg's blog to handle this scenario:

Measure Totals, The Final Word

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Frequent Visitor

Hi there Team,

I have not had a reply as yet on the above question after a solution was given. Kindly help me as I'm not getting the statement to work with additional fields added to the dataset.

Much appreciated,

Neville