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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Trouble Creating Formula Composition by Production Line Using the Divide Function and CALCULATE

Backstory:

We have an MRP system that provides me with two tables, one spits out the amount of each material consumed for a given run (ex. 10,000 lbs of Material A, 3,500 lbs of Material B, etc...) and another table that spits out the total run weight and number of batches (ex. 50 executions/batches (@ 1000 lbs), 50,000 lbs of Product A).  What I am trying to do is determine the percentage composition (on average) of all of our materials across each production line and be able to spot unfavorable trends (due to the nature of our products, the composition changes for a variety of reasons, so Product A won't always be 74% Material A).

 

I would then like to be able to create a table or graph of this data and using a splicer, be able to toggle between views of the different materials, so I wouldn't like material to be "baked" into the DAX formula (as it would create way too many columns/measures with all our formulas, lines, and plants).

 

 

Problem/Attempted Solution:

What I did was try to generate a formula dividing Table 1 (Consumption of each material) by Table 2 (Total Consumption):

Percent Composition = DIVIDE('Table 1'[Quantity], SUM('Table 2'[Quantity]))

I then applied a filter to the table or visual for production, but it wasn't filtering all the data, only those used to calculate the numerator.  For example, if I applied a Line 1 filter, the numerator would be filtered for that, so it would sum all of Material A used during that date range on Line 1, but divide by ALL of the material used in the entire plant, leaving me with a very small, and incorrect, material composition for Material A.

 

I then looked on line and thought the CALCULATE function may be the way to go.  So I tried:

Percent Composition = DIVIDE('Table 1'[Quantity],CALCULATE(SUM('Table 2'[Quantity], 'Table 2'[Line] = "L1'))

Instead of very small numbers, this gave me values over 100%...

I then tried swapping the Table 2 instances in the denominator for Table 1, because the sums should be equivalent, but I got equally bizarre results.

 

Any thoughts?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I was able to get all of my values to be correct by creating a new measure instead of a new column.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I was able to get all of my values to be correct by creating a new measure instead of a new column.

AlB
Community Champion
Community Champion

Hi @Anonymous

 

can you share the pbix?

Anonymous
Not applicable

The data is sensitive since it contains all our formulations for the past four years, so I would be unable to upload it.  I will try to recreate a smaller scale version with dummy materials and data in the interim.

hi, @Anonymous

If you had create the relationship between tables? and If you may try to use ALLxxx functions in your formula.

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

Please share a sample pbix and the expected output. Do mask sensitive data before uploading.

 

 

 

Best Regards,

Lin

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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