Forum Discussion
AndrewH1
8 years agoNew Member
Calculation over specific rows
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 (eithe...
- 8 years ago
You may first Merge Columns and Pivot Column in Query Editor, then use SUMX Function in DAX.
BKirsch12
8 years agoResolver II
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.