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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
mortarotti
Regular Visitor

Cascade Calculation

Hi everyone,

 

I've had some issues about te calculation below. Here is a sample example.

I have two tables, sales and price.

 

Price

MarketLimit VolumeValue1Value2
Residencial103,991,25
Residencial254,991,15
Residencial 5,991,03
Industry10099,990,99
Industry500115,990,93
Industry1000139,990,87
Industry 149,990,85

 

Sales

CustomerMarketVolume
1Residencial15
2Industry600
3Residencial5
4Industry1100
5Industry200

 

The calculation works in cascade, as follows: The Value1 referring to the line where the customer fits, for example the customer 1, with a volume of 15 is in the 2nd line of the Residential Market, since it is greater than the limit of the 1st line that is 10 but smaller than the limit of the 2nd line that is 25. The second step is to cascade the calculation, ie the first 10 units of volume it pays considering Value2 of the 1st line. Excluding the 10 that are already calculated, the remaining 5 are paid considering Value2 of the second line. The sum of these parts divided by the volume is equal to the price paid. I leave the example below in numerical form to facilitate understanding.

 

Customer 1 - Residencial Market - Total Volume: 15

(4.99 + (15-10) * 1.15 + 10 * 1.25) / 15 = 1.55

 

Customer 2 - Industry Market - Total Volume: 600

(139.99 + (600-500) * 0.87 + (500-100) * 0.93 + 100 * 0.99) / 600 = 1.16

 

Customer 3 - Residencial Market - Total Volume: 5

(3.99 + 5 * 1.25) / 5 = 2.05

 

I have no ideia how to make this rule works in dax. Can anyone help me please?

Thanks in advance,

Luis

1 ACCEPTED SOLUTION
Anonymous
Not applicable

1.  Add columns to Price table: Include all of the necessary information for the calculation (except the volume, which comes from the Sales table). Also, Add a key column like "Residential 10-25"

 

2. Add the same key column to the Sales table, so that it will match the new key column in the Price table.

 

3. Create a relationship between the two tables.

 

4. Create a Measure with SUMX: SUMX('Sales', <Formula>)   //Refer to attributes in the Price table like this: Related(Price[Attribute])

 

Calc = SUMX('Sales',
   DIVIDE(
     Related(Price[Upper Value1]
     + ([Volume] - Related(Price[Lower Limit Volume])) * Related(Price[Upper Value2])
     + Related([Lower Limit Volume]) * Related(Price[Lower Value2]),
     [Volume]
   )
) 

Cheers!

Nathan

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

1.  Add columns to Price table: Include all of the necessary information for the calculation (except the volume, which comes from the Sales table). Also, Add a key column like "Residential 10-25"

 

2. Add the same key column to the Sales table, so that it will match the new key column in the Price table.

 

3. Create a relationship between the two tables.

 

4. Create a Measure with SUMX: SUMX('Sales', <Formula>)   //Refer to attributes in the Price table like this: Related(Price[Attribute])

 

Calc = SUMX('Sales',
   DIVIDE(
     Related(Price[Upper Value1]
     + ([Volume] - Related(Price[Lower Limit Volume])) * Related(Price[Upper Value2])
     + Related([Lower Limit Volume]) * Related(Price[Lower Value2]),
     [Volume]
   )
) 

Cheers!

Nathan

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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