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
MattDaddy
Frequent Visitor

Dynamic line chart using measures to calculate weighted averages across column values.

I apologies if this has been addressed, but I'm banging my head looking for a solution.

 

I am working on a dynamic Power BI Report that illustrates a chart showing sales discounts across increasing volume sizes.

 

I have a What-if paremeter that creates a table series of 10-100 at increments of 10.  I then want to calculate a weighted average discount for all values 10 - 100 based on measures selected from slicers (also what-if parameters) that define the discounts for increasing increments.  For example: 

 

The first 20 units sold have a discount factor of 95%, the next 40 units have a discount factor of 75%, and anything above 60 units has a factor of 50%.  The total discount is weighted based on the total units.

 

I can calcualte the weighted discount for any selected volume level by using multiple measures, but I want to show what the discount is across all volume levels in a line chart to assist a sales team in modeling breakpoints and discount factors.

 

I can do all of this easly enough in Excel, but I would like to add this functionality to a BI tool for broader publication.

 

The excel  that shows this working is attached.  The parameters in the example are excel cells that can be edited, and in my Power BI report they are created from individual what-if parameter tables.

 

Thank you

 

xlsl: https://1drv.ms/x/s!Asripv3-9SfJ4S6fRcfHLpxjQOIG?e=HHbbqD

pbix: https://1drv.ms/u/s!Asripv3-9SfJ4S2b9rReLYdDYxkE?e=3icdqE

 

2 REPLIES 2
MattDaddy
Frequent Visitor

@v-xiaotang 

 

The formula generating the series is in column B of the excel file:

 


" =IF($A3<=Tier1,Tier1Discount,
IF(AND($A3>20,$A3<=Tier1+Tier2),(Tier1/$A3)*Tier1Discount+($A3-Tier1)/$A3*Tier2Discount,
IF($A3>(Tier1+Tier2),(Tier1/$A3)*Tier1Discount+(Tier2/$A3)*Tier2Discount+(($A3-Tier2-Tier1)/$A3)*RemainderDiscount,))) "
 
I put name ranges on the formula elements that I hope makes it easier to follow.
 
Thank you for taking a look!
v-xiaotang
Community Support
Community Support

Hi @MattDaddy 

Could you share the calculating formula in that chart? so we can convert it into dax language.

 

Best Regards,

Community Support Team _Tang

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

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.