cancel
Showing results for
Did you mean:
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
Resolver V

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?

 ID Start time Completion time Email Sales Rep Bakery Depot Name Bill To Number (Mosaic Account Number) Store Name Town Name Customer Group From who does this store get their Albany bread? Is there a Pricing Poster in the Store? Does the Store have a Bread Stand? Is the Store GPS Plotted / Geo Coded? Is Tinkies Available in the Store? Is BOB Available in the Store? Are Buns & Rolls Available in the Store? Is Whole Wheat Brown Bread available in the Store? Attribute Value Price Manufacturer Type Sub Type Sort Order Measure Albany Price 22795 ######## ######## Nelson.Maduna@TigerBrands.com Nelson Fanaye Maduna Sasolburg Sasolburg Nathi Tuck Shop Bophelong Independent Albany Directly Yes No Yes Yes No No No Blue Ribbon Classic White RSP 16 R 16.00 Blue Ribbon Superior White 2 RSP 0 15211 ######## ######## Nelson.Maduna@TigerBrands.com Nelson Fanaye Maduna Sasolburg Sasolburg Paulos Tuck Shop Bophelong Independent Albany Directly Yes No Yes Yes No No No Blue Ribbon Classic White RSP 16 R 16.00 Blue Ribbon Superior White 2 RSP 0 22801 ######## ######## Nelson.Maduna@TigerBrands.com Nelson Fanaye Maduna Sasolburg Sasolburg Darso Tuck Shop Bophelong Independent Albany Directly Yes No Yes No No No No Blue Ribbon Classic White RSP 16 R 16.00 Blue Ribbon Superior White 2 RSP 0 37233 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Mega supermarket Wellington Independent Albany Directly Yes Yes Yes No No No No Albany Everyday White RSP 13 R 13.00 Albany Everyday White 1 RSP 13 37238 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Corner Fruit & Veg Wellington Independent Albany Directly Yes Yes No No No No No Albany Everyday White RSP 13 R 13.00 Albany Everyday White 1 RSP 13 37757 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Pick Mor Belhar Independent Albany Directly Yes Yes Yes No Yes Yes Yes Albany Everyday White RSP 1 699.00 R 16.99 Albany Everyday White 1 RSP 16.99 29323 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Brackenfell Supermarket Brackenfell Independent Albany Directly No Yes Yes Yes Yes Yes Yes Sasko More Slices White RSP 15 R 15.00 Sasko Everyday White 3 RSP 0 31799 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Die Rug Superette Paarl Independent Albany Directly No No Yes No No No No Sasko More Slices White RSP 15 R 15.00 Sasko Everyday White 3 RSP 0 33847 ######## ######## lucinda.september@TigerBrands.com Lucinda September Bellville Bellville Maadina Tuck Shop Belhar Independent Albany Directly No Yes Yes No No No No Sasko More Slices White RSP 15 R 15.00 Sasko Everyday White 3 RSP 0

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

Announcements