Forum Discussion

gmasta1129's avatar
gmasta1129
Resolver I
1 year ago
Solved

Measure total incorrect in Table

Hello,

 

I have a pretty simple formula in my measure.  

 

FundStrat% = [% of Eligible Assets] * CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score]))
 
When I add this measure into my table and turn on the "Totals", I do not get the correct value.  Is it not possible to get the correct total for measures? 
 
Please note, I have two filters (dropdown filters) on my table (see below). Not sure if the filters are the issue? 
1. Run Date
2. Facility Code
 
 
  • Hi gmasta1129 

    In Power BI, it’s common to encounter issues where the total row of a measure does not reflect the expected sum of individual rows, and this is due to how DAX measures are evaluated in the context of totals. Your measure, FundStrat% = [% of Eligible Assets] * CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score])), works correctly on a row-by-row basis because the row context allows DAX to evaluate the values of each row individually. However, when the "Total" is calculated, DAX evaluates the measure in the context of the total group, meaning it no longer computes each row individually and sums them, but rather evaluates the expression once over the entire filtered dataset. This can lead to unexpected results—especially when your measure involves row-level multiplication, like multiplying one measure by a row-dependent sum.

     

    Additionally, the presence of filters like "Run Date" and "Facility Code" affects the context in which both the rows and the total are calculated. These filters may restrict the dataset correctly, but they don’t change the fact that totals are computed in a different evaluation context.

     

    To get an accurate total, you may need to rewrite the measure to explicitly aggregate the row-level results. For example, using SUMX, which iterates over each row in a table and performs the calculation per row before summing, can fix this:

    FundStrat% = SUMX(
        VALUES(enav_raw_input[SomeGroupingColumn]),
        [% of Eligible Assets] * CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score]))
    )
    

    Replace SomeGroupingColumn with the column that defines the row-level granularity of your table. This approach forces DAX to mimic row-by-row evaluation even at the total level, providing the accurate sum you expect.

     

6 Replies

  • Hi gmasta1129 

    In Power BI, it’s common to encounter issues where the total row of a measure does not reflect the expected sum of individual rows, and this is due to how DAX measures are evaluated in the context of totals. Your measure, FundStrat% = [% of Eligible Assets] * CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score])), works correctly on a row-by-row basis because the row context allows DAX to evaluate the values of each row individually. However, when the "Total" is calculated, DAX evaluates the measure in the context of the total group, meaning it no longer computes each row individually and sums them, but rather evaluates the expression once over the entire filtered dataset. This can lead to unexpected results—especially when your measure involves row-level multiplication, like multiplying one measure by a row-dependent sum.

     

    Additionally, the presence of filters like "Run Date" and "Facility Code" affects the context in which both the rows and the total are calculated. These filters may restrict the dataset correctly, but they don’t change the fact that totals are computed in a different evaluation context.

     

    To get an accurate total, you may need to rewrite the measure to explicitly aggregate the row-level results. For example, using SUMX, which iterates over each row in a table and performs the calculation per row before summing, can fix this:

    FundStrat% = SUMX(
        VALUES(enav_raw_input[SomeGroupingColumn]),
        [% of Eligible Assets] * CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score]))
    )
    

    Replace SomeGroupingColumn with the column that defines the row-level granularity of your table. This approach forces DAX to mimic row-by-row evaluation even at the total level, providing the accurate sum you expect.

     

  • Deku's avatar
    Deku
    Super User

    What do you mean by wrong? What do you expect?

     

    Can you share the definition of the other measure, what you are seeing now and the expected output.

  • The value (output) in the measure I provided above is calculated correctly. Its when I click on "Totals" in the visualizations section of Power BI. This column does not show the correct total at the bottom of the table I created.

     

    Ex: 

    Fundstrat%

    5

    4

    8

    9

    Total on the Table currently shows= 20,000

    I should see 26 (5+4+8+9)

     

    • Deku's avatar
      Deku
      Super User

      I would suggest showing [% of Eligible Assets] and CALCULATE(SUM(enav_raw_input[Invest. Strat - Risk Parameter Score])) as separate columns in the table to debug.

       

      There is not enough information to understand where your issue is.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi gmasta1129 
    Thank you for reaching out microsoft fabric community forum.

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi gmasta1129 
    I wanted to check if you had the opportunity to review the information provided by Deku . Please feel free to contact us if you have any further questions. If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
    Thank you.