Forum Discussion

losbrincos2's avatar
losbrincos2
Regular Visitor
8 months ago
Solved

Incorrect Total in Power BI Bar Chart When Using Legend

Hello, Good morning,
I have a problem in Power BI that I can’t manage to solve.

In a matrix with coordination data and a calculated measure, the value is correct. Both the individual values and the total are correct.

 

In a bar chart (without a legend), the chart is displayed correctly. Both the individual values and the total are correct.

 

In a bar chart (including a coordination legend), the total doesn’t match.

 

 

 

In a bar chart (including a client legend), the total is well.

 

Metric:

FTE Effective (direct + indirect) (Chargeability) =
(
 ([Time booked (excluding on-call and off-hours)])
 / ([Gross Team Capacity] / [Technicians])
) + 0

 

Time booked (excluding on-call and off-hours) =
CALCULATE(
    SUM('PIVOT'[DURATION]),
    'PIVOT'[ON_CALL] <> "TRUE",
    'PIVOT'[OFF_HOURS] <> "TRUE"
)
 
Gross Team Capacity:  CALCULATE(sum(PEOPLE[Capacity))

 

Technicians: CALCULATE(SUM(PEOPLE[Technicians]))

 

I’ve seen in several forums that this is due to a known issue with totals in Power BI. Can anyone help me?

 

I’ve tried using implicit and explicit measures, but I haven’t been able to solve it.

 

Additionally, I need this measure later to build more measures.

 

Has this happened to anyone?

 

Thank you very much in advance.

Regards

  • HI losbrincos2 ,

    A bar chart total only stays correct when both the numerator and denominator of your measure aggregate the same way across all slices. In your model, one part of the calculation (like Technicians, Gross Team Capacity, or something coming from the Coordination dimension) is likely aggregating differently at the total level than at the category level. This usually happens when there’s mixed granularity (e.g., bookings by day but capacity by month), duplicated or unmatched keys in the Coordination table, or a denominator that isn't additive (such as DISTINCTCOUNT). Once a legend is added, Power BI splits the visual into multiple filter contexts, which forces the denominator to recalculate and that’s why the total shifts only after the legend is introduced. To fix it, validate granularity, make sure the Coordination dimension has clean unique keys, and confirm that the denominator measure behaves the same at both row and total levels. Any filter sensitive part of the measure will cause the total to change whenever a legend is applied.

7 Replies

  • losbrincos2 

     

    Power BI bar chart totals change when adding legend due to filter context differences in your measure.

    FTE Effective =
    VAR TimeBooked = [Time booked (excluding on-call and off-hours)]
    VAR Capacity = [Gross Team Capacity] / [Technicians]
    RETURN
    DIVIDE(TimeBooked, Capacity, 0) + 0

     

    Test in matrix first (should match), then bar chart. Works consistently

     

    If this answer helped, please click Kudos or Accept as Solution.
    -Kedar
    LinkedIn: https://www.linkedin.com/in/kedar-pande

  • losbrincos2 , For sum measure Grand total should match 

    Gross Team Capacity:  CALCULATE(sum(PEOPLE[Capacity))

     

    Technicians: CALCULATE(SUM(PEOPLE[Technicians]))

     

    Also for this grand total should match, if needed use filter 

    Time booked (excluding on-call and off-hours) =
    CALCULATE(
        SUM('PIVOT'[DURATION]),
        filter('PIVOT', 'PIVOT'[ON_CALL] <> "TRUE",
        'PIVOT'[OFF_HOURS] <> "TRUE"
    ))
     
    for this Grand total may not match as this is a ratio and will be recalculated at Grand total level 

    FTE Effective (direct + indirect) (Chargeability) =
    (
     ([Time booked (excluding on-call and off-hours)])
     / ([Gross Team Capacity] / [Technicians])
    )

    If you need sum of Ration , you need to measure like 
     
    FTE Effective Sum  = Sumx(Summarize(Table, Table[Legend COlumn]) , [FTE Effective (direct + indirect) (Chargeability) ] ) 

    You can add columns in Summarize as per need 


     

  • v-sshirivolu's avatar
    v-sshirivolu
    Community Support

    Hi losbrincos2 ,

    I would also take a moment to thank Kedar_Pande  , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
     

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions

     

    • losbrincos2's avatar
      losbrincos2
      Regular Visitor
      Thank you very much for your assistance. Over the weekend, I minimized the data model as much as possible to run a controlled test. I kept only the essential components, and the issue still occurs as soon as I include the coordination dimension. Based on what I’ve been reading, it seems that when a legend is added to a visual, Power BI recalculates the totals by grouping categories, which could be causing the incorrect behavior. Do you have any detailed information on this?
       
       

       

       
       
      with legend 20,02
       
      with out legend (correct value) 20,01
       

      In a table it always looks fine, the problem is when I include the legend. I don't know if you know anything about this; I’ve already asked the community as well (without success). The only recommendation I’ve received is to add a totals table on the right or even include it discreetly inside the chart, but it looks really ugly. Thanks a lot for your help. 

      Regards
      David.
      • v-sshirivolu's avatar
        v-sshirivolu
        Community Support

        HI losbrincos2 ,

        A bar chart total only stays correct when both the numerator and denominator of your measure aggregate the same way across all slices. In your model, one part of the calculation (like Technicians, Gross Team Capacity, or something coming from the Coordination dimension) is likely aggregating differently at the total level than at the category level. This usually happens when there’s mixed granularity (e.g., bookings by day but capacity by month), duplicated or unmatched keys in the Coordination table, or a denominator that isn't additive (such as DISTINCTCOUNT). Once a legend is added, Power BI splits the visual into multiple filter contexts, which forces the denominator to recalculate and that’s why the total shifts only after the legend is introduced. To fix it, validate granularity, make sure the Coordination dimension has clean unique keys, and confirm that the denominator measure behaves the same at both row and total levels. Any filter sensitive part of the measure will cause the total to change whenever a legend is applied.

  • Hello, 
    Thank you very much for your assistance. Over the weekend, I minimized the data model as much as possible to run a controlled test. I kept only the essential components, and the issue still occurs as soon as I include the coordination dimension. Based on what I’ve been reading, it seems that when a legend is added to a visual, Power BI recalculates the totals by grouping categories, which could be causing the incorrect behavior. Do you have any detailed information on this?
     
     

     

    with legend 20,02

    with out legend 20,01 (correct value)

     

    In a table it always looks fine, the problem is when I include the legend. I don't know if you know anything about this; I’ve already asked the community as well (without success). The only recommendation I’ve received is to add a totals table on the right or even include it discreetly inside the chart, but it looks really ugly. Thanks a lot for your help. 
    Regards
    David.