Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
I'm still new to Power BI, and right now I have a problem with what I believe is data being summed at the wrong time. I have a table that is organized by region, date, commodity, scenario (either the forecast or budget), metric (either volume or price) and then there is the value. Each row is one of those combinations, i.e. the forecasted price, budgeted price, or forecasted volume. I'm trying to calculate the future budget impact using (Forecast - budget) * volume, but I am having trouble with the result being far off when more than one region/commodity/date is selected.
The original solution, which I believe causes it to sum the data before doing the calculation is Impact = ((CALCULATE(Sum(Main[Value]), Main[Scenario]="Forecast", Main[Metric]="Price")-CALCULATE(Sum(Main[Value]), Main[Scenario]="Budget",Main[Metric]="Price")))*(CALCULATE(Sum(Main[Value]), Main[Scenario]="Forecast", Main[Metric]="Volume")).
Instead I want it to do the calculation, then sum over the possibilities. (I believe it does (Σforecast - Σbudget) * Σvolume, when I want Σ((forecast - budget) * volume)) ) I've been trying to filter out the different types of values, but have had no luck so far. Any help or solution to this would be amazing.
Thanks!
Example table
Solved! Go to Solution.
You may first Merge Columns and Pivot Column in Query Editor, then use SUMX Function in DAX.
You may first Merge Columns and Pivot Column in Query Editor, then use SUMX Function in DAX.
I've found the using multiple measures makes the code easier to follow, as well as either to work with. I'd recommend you use your current code to make 4 measures.
Forecasted Price = CALCULATE(Sum(Main[Value]), Main[Scenario]="Forecast", Main[Metric]="Price")
Budgeted Price =CALCULATE(Sum(Main[Value]), Main[Scenario]="Budget",Main[Metric]="Price")
Forecasted Volume =CALCULATE(Sum(Main[Value]), Main[Scenario]="Forecast", Main[Metric]="Volume")
Your Calculation = (Forecasted Price - Budgeted Price) * Forecasted Volume
As far as displaying the information, you'll need to decide how to do that (By Commodity Type, etc.).
Let me know if this helps.
User | Count |
---|---|
85 | |
82 | |
66 | |
52 | |
48 |
User | Count |
---|---|
100 | |
49 | |
42 | |
39 | |
38 |