Forum Discussion

margaretaak's avatar
margaretaak
Frequent Visitor
9 months ago
Solved

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.67

     

    2. 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

  • 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.67

     

    2. 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-prasare's avatar
    v-prasare
    Community 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-prasare's avatar
    v-prasare
    Community 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