Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BrianNeedsHelp
Helper III
Helper III

Total Is Correct but row is not when using ALL

Biggest puzzler yet:  I have this measure called [%Need].  The sum total of these percentages needs to be 1 in order to compute correctly.  However, it's not, so in order to correct it I need to do a formula like:  [%Need]/Sum [%Need] *1.  So in order to get sum portion  I did:  

CALCULATE(SUMX(VALUES('Calendar'[calendar date]),[%Need]),ALL('Calendar'[CalendarDate]))

This puts 1(I checked it out to 15 0s 1.00000000000000 in each row instead of the correct amount which is 1.0147.  1.0147 however appears in the Total at the bottom.  I need 1.0147 in each row so I can have it divided by [%Need].    This probably doesn't need to be included, but just in case the [%Need] measure is:  

IF([CALendarDATE]>LASTNONBLANK ( 'Calendar'[Calendar Date], [Gross Adds]),[PYGA]/([PYALLGAs]-[GAsLyMAXDateAll]),Blank())

Any idea how to get the correct total in each row?  

 

2 REPLIES 2
FarhanJeelani
Super User
Super User

Hi @BrianNeedsHelp,

The issue arises because DAX treats row context and filter context differently when calculating totals versus individual rows. Here's a breakdown of what's happening and how to fix it:

Problem:

  1. The total row correctly shows 1.0147, but individual rows incorrectly show 1.0000.
  2. This is because you're using ALL('Calendar'[CalendarDate]), which removes the filter context for the column. This causes the calculation to consider all dates, not just the rows' specific contexts.

Solution:

You want each row to reflect the correct percentage by dividing the row's %Need value by the sum total (1.0147). To achieve this:

Corrected Measure

[%Need Adjusted] =
VAR TotalNeed =
    CALCULATE(SUMX(VALUES('Calendar'[Calendar Date]), [%Need]), ALL('Calendar'))
RETURN
    DIVIDE([%Need], TotalNeed)

Why This Works:

  1. CALCULATE with ALL:

    • The ALL function removes all filters on the Calendar table, ensuring that the total sum of %Need is calculated across the entire dataset.
  2. Row-Level Context:

    • Within each row, %Need is calculated based on the current filter context.
    • The TotalNeed variable ensures you're dividing each row's %Need by the same total value.
  3. DIVIDE for Safety:

    • Using DIVIDE avoids division-by-zero errors and is best practice for these scenarios.

Debugging and Validation

  1. Add a temporary measure to verify the TotalNeed:

    TotalNeed = CALCULATE(SUMX(VALUES('Calendar'[Calendar Date]), [%Need]), ALL('Calendar'))

    This should return 1.0147 consistently across all rows.

  2. Test the %Need Adjusted measure in your table visual.

Let me know if this resolves the issue or if you need further clarification!

 

Please mark this as solution if it helps you. Appreciate Kudos

Thanks for your reply and explanation.  However that measure does the same thing.  1 in all the rows and 1.0147 in the total.  

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.