Forum Discussion
Different Calculations
Why are the calculations in the Power BI visualization and in the DAX different? I use AVERAGE in the visualization and the result is 464252.5, I use AVERAGE in the DAX and the result is 12505.94. Even though the data source is the same, the filter is the same, and when I use SUM the results are the same (SUM in the visualization = SUM in the DAX = 4076935.50). I don't have any page-level filters. Am I missing something?
Hi margaretaak
This happens because Power BI visuals and DAX evaluate context differently.
When you drag a numeric field (e.g., Average of [Sales]) into a visual, Power BI averages all visible rows directly.
But when you use a DAX measure like:Row-based Average
Avg_Sales = AVERAGE('Table'[Sales])It averages within each filter or group in the visual ,not across all raw rows.
That’s why SUM gives identical results (it’s additive), but AVERAGE doesn’t ,it depends on the level of aggregation.
Context-based Average
Avg_Sales_ByCustomer = AVERAGEX( VALUES('Table'[Customer]), CALCULATE(SUM('Table'[Sales])) )In nut shell-The visual’s average is row-based, while your DAX measure is context-based. SUM matches; AVERAGE can differ because of grouping level.
For example:-
Sample data
1. Row-based Average-
This averages the Sales column over all visible rows in the current filter context.
If there are 3 rows (100, 300, 1000), it gives:
(100 + 300 + 1000) / 3 = 466.672. Context-based Average-
-
First, Power BI creates one row per Customer (A and B).
-
Then it calculates each customer’s total:
-
A → 100 + 300 = 400
-
B → 1000
-
-
Finally, it averages those totals: (400 + 1000) / 2 = 700
-
3 Replies
- rohit1991Super User
Hi margaretaak
This happens because Power BI visuals and DAX evaluate context differently.
When you drag a numeric field (e.g., Average of [Sales]) into a visual, Power BI averages all visible rows directly.
But when you use a DAX measure like:Row-based Average
Avg_Sales = AVERAGE('Table'[Sales])It averages within each filter or group in the visual ,not across all raw rows.
That’s why SUM gives identical results (it’s additive), but AVERAGE doesn’t ,it depends on the level of aggregation.
Context-based Average
Avg_Sales_ByCustomer = AVERAGEX( VALUES('Table'[Customer]), CALCULATE(SUM('Table'[Sales])) )In nut shell-The visual’s average is row-based, while your DAX measure is context-based. SUM matches; AVERAGE can differ because of grouping level.
For example:-
Sample data
1. Row-based Average-
This averages the Sales column over all visible rows in the current filter context.
If there are 3 rows (100, 300, 1000), it gives:
(100 + 300 + 1000) / 3 = 466.672. Context-based Average-
-
First, Power BI creates one row per Customer (A and B).
-
Then it calculates each customer’s total:
-
A → 100 + 300 = 400
-
B → 1000
-
-
Finally, it averages those totals: (400 + 1000) / 2 = 700
-
- v-prasareCommunity Support
Hi margaretaak,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?
rohit1991, Thanks for your prompt response
Your feedback is important to us, Looking forward to your response
Thanks,
Prashanth
- v-prasareCommunity Support
Hi @margaretaak,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by community members for your issue worked for you or let us know if you need any further assistance?
Your feedback is important to us, Looking forward to your response
Thanks,
Prashanth