Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a data set that has fiscal year, material group, market segment, material, product tonnes and N tonnes. I have also added the calculated columns of N tonnes, direct emissions, indirect emissions and total emissions (which uses market segment and N tonnes).
i need to model the effect of changing tonnes on emissions. i have tried but am in a tangle.
i created a list of the material groups and added two more:
Thank you for your help. I really appreciate it as am new to this.
I have applied the changes and how when i create a table using this i get data - which i wasn't before.
However, if i just use the material group list the two new categories are there. But when i add the new measure they disappear.
Also the sums for the groups i am changing are wrong. For example, with the parameter set to zero the urea granular total = 805,643,294 instead of 874,848.
Re the parameter values, they aren't linked in the data structure to the sales data table a when i do i get no data?
It seems like you're trying to model the effect of changing product tonnes on emissions for different material groups in your dataset using Power BI or a similar tool. Your approach is on the right track, but there are a few issues in your DAX measures. Let's break down the issues and provide a corrected version:
Parameter Setup: Ensure that your parameters are correctly set up to allow dynamic changes. It seems like you've already set them up, but make sure they are appropriately linked to your report.
Material Group Addition: It's good that you've added the "Coated Urea" and "Coated Blends" material groups. Ensure that these are distinct from the original groups.
DAX Measures: Your DAX measures need some adjustments:
GUreduction and UBreduction should calculate the reduction in tonnes based on the parameters, but your current formulas are not correctly structured. Here's a corrected version:
var GUreduction = SUMX('Sales Data', IF('Sales Data'[Material group] = "Urea Granular", 'Sales Data'[Product Tonne] - ('Sales Data'[Product Tonne] * [Parameter Value])))
var UBreduction = SUMX('Sales Data', IF('Sales Data'[Material group] = "Urea Blends", 'Sales Data'[Product Tonne] - ('Sales Data'[Product Tonne] * [Parameter Value3])))
CoatedUrea and CoatedUB should calculate the new tonnes after reduction. Here's a corrected version:
var CoatedUrea = SUMX('Sales Data', IF('Sales Data'[Material group] = "Coated Urea", 'Sales Data'[Product Tonne] + ('Sales Data'[Product Tonne] * [Parameter Value])))
var CoatedUB = SUMX('Sales Data', IF('Sales Data'[Material group] = "Coated Blends", 'Sales Data'[Product Tonne] + ('Sales Data'[Product Tonne] * [Parameter Value3])))
PTmodelling can be simplified. Here's a corrected version:
var PTmodelling =
SWITCH(
TRUE(),
'Sales Data'[Material group] = "Urea Granular", GUreduction,
'Sales Data'[Material group] = "Coated Urea", CoatedUrea,
'Sales Data'[Material group] = "Urea Blends", UBreduction,
'Sales Data'[Material group] = "Coated Blends", CoatedUB,
'Sales Data'[Material group] = "EEF Blends", 'Sales Data'[Product Tonne] + ('Sales Data'[Product Tonne] * [Parameter Value2]),
'Sales Data'[Product Tonne]
)
Total Emissions: You mentioned that you also want to calculate total emissions based on market segment and the modified N tonnes. Ensure that your calculation for total emissions is correctly updated based on these modifications.
With these adjustments, your DAX measures should provide the desired modeling effect for changing tonnes on emissions for different material groups. Remember to link the parameters to your report so that you can interactively change the values and see the impact on your visualizations.
Thanks v much for your help. I have adjusted my DAX measures but am still getting an error with the PTmodelling.
It is saying...
"A single value for column 'Material group' in table 'Sales Data' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifiying an aggregation such as min, max, count, or sum to get a single result.
The error message you're encountering, "A single value for column 'Material group' in table 'Sales Data' cannot be determined," indicates that your DAX measure is trying to use a column in a context where it expects a single value, but it's getting multiple values. This often happens when you're using a measure in a way that requires aggregation at a lower granularity level.
In your PTmodelling measure, you are using several IF statements, and each of them works within a filter context. When you filter your data based on material groups, the measure needs to return a single value for each row in the Sales Data table. However, your PTmodelling measure doesn't do that, which is causing the error.
To resolve this issue, you should modify your PTmodelling measure to return a single value for each row in the Sales Data table. You can achieve this by aggregating the values for each material group using functions like SUMX, MAXX, or MINX. Here's an updated version of your PTmodelling measure using SUMX:
x Product Tonne modeling =
SUMX(
'Sales Data',
VAR MaterialGroup = 'Sales Data'[Material group]
RETURN
SWITCH (
TRUE (),
MaterialGroup = "Urea Granular", GUreduction,
MaterialGroup = "Coated Urea", CoatedUrea,
MaterialGroup = "Urea Blends", UBreduction,
MaterialGroup = "Coated Blends", CoatedUB,
MaterialGroup = "EEF Blends", EEFBlendIncrease,
'Sales Data'[Product Tonne]
)
)
This updated measure uses SUMX to iterate over each row in the Sales Data table and applies the calculations based on the Material Group. Make sure your other measures (GUreduction, CoatedUrea, UBreduction, CoatedUB, EEFBlendIncrease) are correctly defined as well.
Remember to ensure that your parameter values are correctly defined and that the data model is set up properly for these calculations to work as intended.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Apologies to keep asking about this but i am still having trouble.
Your code works for the original material groups but not for the two i have added.
To add the two additional material groups i created a calculated table using
I linked this to another table 'Sales Data' which has the product tonnes.
I then created a measure in 'MatGroup change' to asign product tonnes.
what is happening is that the right tonnes are asigning to the original mat groups, but the two new ones are not in the list. if i create a table of the mat groups alone the two new ones show. they disappear once the measure is added.
i have tried the code different ways and in different configurations and i can't get it to work.
What am i doing wrong?
Thank you for this. I have adjusted the formula as above. I now don't have the error message.
However, I still have something wrong that I can't work out.
the added material groups are showing, but when i add the measure to the table they are not there.
In addition the equation are adding incorrectly. for example, when the parameters are set to zero urea granular shows 3 billion not 874,000. its not the sum of all the values so not sure what it is doing.
The field parameters were created using the function under the modelling tab. I haven't connected them to the 'sales data' table as when I do I get nothing in the table - no material group list and no data.
Update the maths is now working and adjusting correctly with the field parameters.
But ... the two material groups i have added are not showing in the table.
Hi,No problem, I was away for 5 days but I'm back in my hometown now. Please provide a detailed description of the issue in a business-oriented manner, and I'll do my best to address it promptly.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
It is essentially a 'what if' modelling exercise.
I have a large table of sales data by product and each product is asigned a material group. I have added calculated columns to the table to calculate emissions for each product; and a measure for the sum of emissions.
I need to model what happens if I change three of the material groups.
1) dynamically decrease the volume of two material groups and assign the reduction to two new material groups.
2) dynamically increase the volume of another material group.
The rest of the material groups stay the same.
Then once i can do this i can use the method to recalculate the associated emissions.
User | Count |
---|---|
77 | |
76 | |
41 | |
30 | |
24 |
User | Count |
---|---|
97 | |
91 | |
52 | |
47 | |
46 |