Forum Discussion

mogugu_84's avatar
mogugu_84
Helper I
1 year ago
Solved

bar chart total issue

I have a simple stacked bar chart like the below, each color is like one State, and the measure is like "sum of units", very simple, 

i.e. like the below in March, the 7 States adds up to totally 4519 units, which is the correct number.

 i also have a 2nd layer of the geogrphy, which is "City", each State above are consisted by a bunch of Cities. When i put "City" into the legend instead of the "State", the total is less (consistantly each month), see below, March is only 4,283 units. 

the part that i can't diagnose is that i filtered for each State in the city view chart, for example, below is the city breakdown for bottom State (see the State view chart), dark green color, showing 607 units, and the breakdown below adds up to 607 correctly. i checked all State individually, it's all correct. 

i also check the "show as table" for the total city view, each number of March adding together still equals 4719, but why the bar total shows 4283....anyone knows why?

 

  • Hi mogugu_84 ,

    If all cities have values, the matrix and stacked bar chart totals should match. The issue is that Power BI’s stacked bar chart may skip some cities due to its data reduction for performance, causing a lower total than the matrix which shows all data, like your correct 4708 total. Zero value cities might add rows in the matrix but don’t affect the sum, so the discrepancy is purely visual.

    If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

    Best Regards,
    Harshitha.
    Community Support Team

11 Replies

  • ExcelMonke's avatar
    ExcelMonke
    Impactful Individual

    Hello,

    Without knowing much about how your data is set up, it is difficult to say if this is a DAX formula issue or a data issue. I would need to know a little bit more about how the data is set up. One thing to consider is to check whether your Location Dim table (the table where you have your state/city) information is set up correctly. i.e. Do all the cities have state values, and vice versa. 

    One way to continue diagnosing is to create a matrix, where your rows are State, City, and from there see if you are able to determine which cities (or blanks!) are not returning any results. 

    • mogugu_84's avatar
      mogugu_84
      Helper I

      Hi ExcelMonke

      thanks for your suggestion on using a matrix table, here's some updated information:

       

      when not expanded, just showing at the State (provincia) level, the table and bar chart is aligned

       

      simply expand the matrix table, the total is still correct in the table, but when replacing the legend to city in the bar chart, the total reduces

       

      there's no DAX formula for the measure, it's just a simply auto sum of a column called "Units"

      I have also double check the relationship structure between State and City, it's all unique otherwise the matrix table won't be correct anyway? it's really weird...

       

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

        Hi mogugu_84,

        The matrix includes all rows even those with blanks or zero values while the bar chart automatically excludes categories (cities) with blank or zero totals from the visual, which causes the total to reduce.

        This behavior is expected in visuals like stacked bar charts, as Power BI doesn’t display or count in total height categories with no visible bars.

        If I misunderstand your needs or you still have problems on it, please feel free to let us know.  
        If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

        Best Regards,
        Harshitha.
        Community Support Team

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

    Hi mogugu_84,
    Thank you ExcelMonke, for your response regarding the Issue.
    Thank you for reaching out to the Microsoft fabric community forum.

    Here are the few steps which you may follow to resolve the issue :
    1.Make sure that the relationship between your tables is properly established.
    2. Ensure Your DAX correctly sums the Total Units at both the State and City levels.


    Please find the attached file for your reference.
    If you're still facing any issues, consider sending sample data.

    You can refer the following links:

    How to provide sample data in the Power BI Forum - Microsoft Fabric Community
    Solved: How to upload PBI in Community - Microsoft Fabric Community

    Hope this helps!
    If the response has addressed your query, please accept it as a solution and give a'Kudos' so other members can easily find it.
    Thank You!

     

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

      Hi mogugu_84,
      Just wanted to check if you had the opportunity to review the suggestion provided?
      If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

      Thank You.

    • mogugu_84's avatar
      mogugu_84
      Helper I

      Hi

      thank you, I'm travelling at the moment but will definitely check and feedback as soon as I can. 

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

        Hi mogugu_84 ,

        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. If my response has addressed your query, please Accept it as a solution so that other community members can find it easily.

         

        Best Regards,
        Harshitha.
        Community Support Team.