Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello Power BI Community,
I am facing a challenge in my Power BI report where the dynamic calculations for a measure, scope-based emissions, do not align with average emissions under certain conditions, specifically when no scopes or all scopes are selected. I expect these conditions to yield identical results in two different line charts, but they do not.
Issue Description:
Line Chart Discrepancy: When no scopes or all scopes are selected, the line chart for "Dynamic Scope Emissions" should mirror the chart for "Avg Asset GHG Emissions (CO2e per $’m)," but the results differ.
Table Totals Mismatch: The total values in my data table for "Dynamic Scopes Emissions" do not match those for "Avg Emissions per Revenue (per Sm)", indicating a potential issue in how totals are computed.
Current Setup:
1. I use a custom table for scope selections called "Scope Options", defined as follows:
Scope Options =
DATATABLE(
"Scope", STRING,
"Selected", BOOLEAN,
{
{"Scope 1", FALSE},
{"Scope 2", FALSE},
{"Scope 3", FALSE}
}
)
2. Dynamic Scopes Emissions Formula: This formula is designed to dynamically sum emissions based on selected scopes and calculate average emissions per million USD of revenue. The formula and its components are intended to adjust based on the slicer's scope selection:
Dynamic Scopes Emissions =
VAR IsScope1 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 1")
VAR IsScope2 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 2")
VAR IsScope3 = CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 3")
VAR ScopeSum =
SUM(ESG_Assets_Data_Pivot[scope1]) * IsScope1 +
SUM(ESG_Assets_Data_Pivot[scope2]) * IsScope2 +
SUM(ESG_Assets_Data_Pivot[scope3]) * IsScope3
VAR TotalRevenue = SUM(ESG_Assets_Data_Pivot[revenue_usd])
VAR Default = NOT(IsScope1 || IsScope2 || IsScope3) // True if no scopes are selected
RETURN
DIVIDE(
IF(
Default,
SUMX(
VALUES(ESG_Assets_Data_Pivot[company_name]),
SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3])
),
ScopeSum
),
TotalRevenue / 1000000,
BLANK()
)
3. Additional Measure for Context: "Average Emissions Per Revenue (per mil)" is used to provide a high-level view of emissions efficiency per revenue, calculated as:
Average Emissions Per Revenue (per mil) =
AVERAGEX(
VALUES(ESG_Assets_Data_Pivot[company_name]),
DIVIDE(
[Total Emissions],
SUM(ESG_Assets_Data_Pivot[revenue_usd]) / 1000000,
0
)
)
Where "Total Emissions" is calculated as follows, summing emissions from all three scopes if any are greater than 0.1:
Total Emissions =
IF(
SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3]) > 0.1,
SUM(ESG_Assets_Data_Pivot[scope1]) + SUM(ESG_Assets_Data_Pivot[scope2]) + SUM(ESG_Assets_Data_Pivot[scope3]),
BLANK()
)
Asset | Avg Emissions per Revenue (using total emissions) | Dynamic Scope Emissions | scope 1 | scope 2 | scope 3 | revenue | Total Emissions | |
A | 0.22 | 0.22 | 0 | 0 | 12.97 | $58,286,725.86 | 12.97 | |
B | 292.95 | 292.95 | 122.22 | 129.13 | 31769.37 | $109,302,981.64 | 32,020.72 | |
C | 307.78 | 307.78 | 1206 | 1128 | 116905 | $387,421,494.72 | 119,239 | |
Total | 90.85 | 272.56 | 1328.22 | 1257.13 | 148687.34 | $555,011,202.23 | 151,272.69 |
Objective:
The "Dynamic Scope Emissions" should accurately reflect the combination of selected scopes and match the "Avg Asset GHG Emissions" when either all scopes or no scopes are selected.
What I've Tried:
Verified slicers are correctly linked.
Checked individual asset data which appears accurate.
Reassessed formulas for any logical or contextual errors.
Request for Assistance: Could anyone help identify why these discrepancies occur or suggest modifications to ensure the DAX formula works as intended? Insights into correcting these values would be immensely appreciated.
Thank you for your time and help!
Solved! Go to Solution.
The discrepancy between "Dynamic Scope Emissions" and "Avg Asset GHG Emissions" arises from differences in how totals are calculated in DAX versus row-level data. To fix this:
Dynamic Scope Emissions Fix: Ensure the measure calculates totals correctly when no scopes or all scopes are selected. Update it to handle "no scope selected" with a default sum of all scopes.
Dynamic Scopes Emissions =
VAR Default = NOT (CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 1") ||
CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 2") ||
CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 3"))
VAR ScopeSum =
SUM(ESG_Assets_Data_Pivot[scope1]) * IsScope1 +
SUM(ESG_Assets_Data_Pivot[scope2]) * IsScope2 +
SUM(ESG_Assets_Data_Pivot[scope3]) * IsScope3
RETURN
DIVIDE(IF(Default, TotalAllScopes, ScopeSum), TotalRevenue / 1_000_000, BLANK())
Average Emissions Per Revenue (per mil) =
AVERAGEX(VALUES(ESG_Assets_Data_Pivot[company_name]), [Total Emissions] / RevenuePerMil)
Debug_Total_Emissions = SUMX(VALUES(ESG_Assets_Data_Pivot[company_name]), RowEmissions)
Validate in a Matrix: Test scenarios with all/no scopes selected to ensure calculations align.
By correcting total-level aggregation and validating slicer interactions, both measures will align across visuals and totals.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Hi @user_guddu10 ,
Thank you for your interest in this case.
My following up is just to ask if the problem has been solved?
If so, can you accept the correct answer as a solution or share your solution to help other members find it faster?
Thank you very much for your cooperation!
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
The discrepancy between "Dynamic Scope Emissions" and "Avg Asset GHG Emissions" arises from differences in how totals are calculated in DAX versus row-level data. To fix this:
Dynamic Scope Emissions Fix: Ensure the measure calculates totals correctly when no scopes or all scopes are selected. Update it to handle "no scope selected" with a default sum of all scopes.
Dynamic Scopes Emissions =
VAR Default = NOT (CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 1") ||
CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 2") ||
CONTAINSROW(VALUES('Scope Options'[Scope]), "Scope 3"))
VAR ScopeSum =
SUM(ESG_Assets_Data_Pivot[scope1]) * IsScope1 +
SUM(ESG_Assets_Data_Pivot[scope2]) * IsScope2 +
SUM(ESG_Assets_Data_Pivot[scope3]) * IsScope3
RETURN
DIVIDE(IF(Default, TotalAllScopes, ScopeSum), TotalRevenue / 1_000_000, BLANK())
Average Emissions Per Revenue (per mil) =
AVERAGEX(VALUES(ESG_Assets_Data_Pivot[company_name]), [Total Emissions] / RevenuePerMil)
Debug_Total_Emissions = SUMX(VALUES(ESG_Assets_Data_Pivot[company_name]), RowEmissions)
Validate in a Matrix: Test scenarios with all/no scopes selected to ensure calculations align.
By correcting total-level aggregation and validating slicer interactions, both measures will align across visuals and totals.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Hi John,
I really appreciate your time. I applied the changes you suggested but they did not give a favourable outcome.
- There was no change in Dynamic Scopes Emissions. It is still displaying the same total on the table and line chart.
- Average emissions per revenue was showing valid data before but with the new formula the line chart shows inaccurate data when I try to validate the line chart with a data in a table.
1. Line chaft with original DAX measures:
2. Line chart after changes:
3.This table is showing the count of assets (known as company_name) per year.
Note: The dynamic scope emissions chart should show the same data when all 3 scopes are selected as the chart above.
When using an iterator you need to force context transition by either calling CALCULATE or by using a measure, in which case CALCULATE is implicitly called.
Try
Dynamic Scopes Emissions =
VAR IsScope1 =
CONTAINSROW ( VALUES ( 'Scope Options'[Scope] ), "Scope 1" )
VAR IsScope2 =
CONTAINSROW ( VALUES ( 'Scope Options'[Scope] ), "Scope 2" )
VAR IsScope3 =
CONTAINSROW ( VALUES ( 'Scope Options'[Scope] ), "Scope 3" )
VAR ScopeSum =
SUM ( ESG_Assets_Data_Pivot[scope1] ) * IsScope1
+ SUM ( ESG_Assets_Data_Pivot[scope2] ) * IsScope2
+ SUM ( ESG_Assets_Data_Pivot[scope3] ) * IsScope3
VAR TotalRevenue =
SUM ( ESG_Assets_Data_Pivot[revenue_usd] )
VAR Default = NOT ( IsScope1 || IsScope2
|| IsScope3 ) // True if no scopes are selected
RETURN
DIVIDE (
IF (
Default,
SUMX (
VALUES ( ESG_Assets_Data_Pivot[company_name] ),
CALCULATE (
SUM ( ESG_Assets_Data_Pivot[scope1] ) + SUM ( ESG_Assets_Data_Pivot[scope2] )
+ SUM ( ESG_Assets_Data_Pivot[scope3] )
)
),
ScopeSum
),
TotalRevenue / 1000000,
BLANK ()
)
Average Emissions Per Revenue (per mil) =
AVERAGEX (
VALUES ( ESG_Assets_Data_Pivot[company_name] ),
DIVIDE (
[Total Emissions],
CALCULATE ( SUM ( ESG_Assets_Data_Pivot[revenue_usd] ) ) / 1000000,
0
)
)
Your total measure would be more efficient using variables
Total Emissions =
VAR Scope1 =
SUM ( ESG_Assets_Data_Pivot[scope1] )
VAR Scope2 =
SUM ( ESG_Assets_Data_Pivot[scope2] )
VAR Scope3 =
SUM ( ESG_Assets_Data_Pivot[scope3] )
VAR Result =
IF ( Scope1 + Scope2 + Scope3 > 0.1, Scope1 + Scope2 + Scope3, BLANK () )
RETURN
Result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
10 | |
9 | |
9 |
User | Count |
---|---|
15 | |
12 | |
11 | |
11 | |
11 |