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
kukszi
Helper I
Helper I

Build a model to extrapolate sales volume

Hi there,

I need to build a model in Power BI which extrapolates sales numbers, but I don't know how to start. The concept is the following: I have sales volume for Ontario and BC, and would like to extrapolate in order to get the total Canada sales.

The data I have is the following:

Actuals:

Customer  Province  Product  Volume  
Cust 1ONProd 1100
Cust 1ONProd 2200
Cust 1BCProd 180
Cust 1BCProd 2170
Cust 2ONProd 1500
Cust 2ONProd 2350
Cust 2BCProd 1200
Cust 2BCProd 2300

Extrapolation parameters:

Customer  In Province  Base to be used  Extrapolation factor
Cust 1ABON70%
Cust 1SKON40%
Cust 2ABBC110%
Cust 2SKBC60%

 

Expected outcome:
Cust 1:
ON Prod 1 = 100
ON Prod 2 = 200
BC Prod 1 = 80
BC Prod 2 = 170
AB Prod 1 = 100 x 70% = 70
AB Prod 2 = 200 x 70% = 140
SK Prod 1 = 100 x 40% = 40
SK Prod 2 = 200 x 40% = 80
Total National Sales to Cust 1 = 880

Cust 2:
ON Prod 1 = 500
ON Prod 2 = 350
BC Prod 1 = 200
BC Prod 2 = 300
AB Prod 1 = 200x 110% = 220
AB Prod 2 = 300x 110% = 330
SK Prod 1 = 200x 60% = 120
SK Prod 2 = 300x 60% = 180
Total National Sales to Cust 2 = 2200

Total National Sales to Cust 1 and Cust 2 = 3080

 

What is the best way to build a calculation like the above explained?

 

Thanks in advance!

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Here is one way to do it.

 

1. Make two DAX tables for Customers and Provinces with these two expressions

Customers = DISTINCT(UNION(VALUES(Actuals[Customer ]), VALUES(Extrapolate[Customer ])))
Provinces = DISTINCT(UNION(VALUES(Actuals[Province ]), VALUES(Extrapolate[In Province ])))
 
2.  Make relationships from these two tables to each of your original tables (in Extrapolate table, the relationship is to the [In Province] column.
 
3.  Make a table visual with Customer (from new table), Province (from new table) and Product (from Actuals table), along with this measure:
Extrapolated Total =
VAR __actuals =
SUM ( Actuals[Volume ] )
VAR __extrapolation =
SUMX (
Extrapolate,
Extrapolate[Extrapolation factor]
* CALCULATE (
SUM ( Actuals[Volume ] ),
ALLEXCEPT ( Actuals, Actuals[Product ] ),
TREATAS ( VALUES ( Extrapolate[Base to be used ] ), Actuals[Province ] ),
TREATAS ( VALUES ( Extrapolate[Customer ] ), Actuals[Customer ] )
)
)
RETURN
__actuals + __extrapolation
 
And you will get this table
 
extrapolate.png
 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
mahoneypat
Employee
Employee

Here is one way to do it.

 

1. Make two DAX tables for Customers and Provinces with these two expressions

Customers = DISTINCT(UNION(VALUES(Actuals[Customer ]), VALUES(Extrapolate[Customer ])))
Provinces = DISTINCT(UNION(VALUES(Actuals[Province ]), VALUES(Extrapolate[In Province ])))
 
2.  Make relationships from these two tables to each of your original tables (in Extrapolate table, the relationship is to the [In Province] column.
 
3.  Make a table visual with Customer (from new table), Province (from new table) and Product (from Actuals table), along with this measure:
Extrapolated Total =
VAR __actuals =
SUM ( Actuals[Volume ] )
VAR __extrapolation =
SUMX (
Extrapolate,
Extrapolate[Extrapolation factor]
* CALCULATE (
SUM ( Actuals[Volume ] ),
ALLEXCEPT ( Actuals, Actuals[Product ] ),
TREATAS ( VALUES ( Extrapolate[Base to be used ] ), Actuals[Province ] ),
TREATAS ( VALUES ( Extrapolate[Customer ] ), Actuals[Customer ] )
)
)
RETURN
__actuals + __extrapolation
 
And you will get this table
 
extrapolate.png
 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat,
This is great, thank you very much. The values in the "Extrapolated Total" column are calculated properly, but when I'm summarizing the individual rows, the result is 3,080 and not 7,220. How can I fix the totals?
Thanks,
Kukszi

Not sure what you mean.  Are you using the measure in a matrix visual?  What is the field for columns?  In any case, total problems are often solved with this kind of an approach:

 

IteratorMeasure = SUMX(VALUES(Table[RowOrColumn in Visual]), [Extrapolated Total])

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


I'm using table visual as you suggested, which looks like this:

image.png

 

Also, tried the IteratorMeasure, which gave a completely different result.

 

When I'm adding up manually the values in Extrapolated Totals column, I get 3080 and not 7220. Am I doing something wrong?

 

Hi @kukszi ,

Please try to update the formula of measure "IteratorMeasure" as below:

IteratorMeasure= SUMX(VALUES('Customers'[Customer]),SUMX(VALUES('Provinces'[Province]), SUMX(VALUES('Actuals'[Product]),[Extrapolated Total])))

iterator measure.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Rena, it worked!

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.