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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
thampton
Helper III
Helper III

Stacked bar chart - % of total

This might be a simple fix, im not sure. 

 

I have a simple table (shown below). Essentially what i want is a stacked bar chart show progress to the total.

 

Label                      Tasks Needed                     Tasks Completed

Name                     10                                       5

 

 

When i create the bar chart, the %'s are using a total of 15 instead of 10. So it would show 30% instead of 50%, when comparing completed tasks to total. 

 

Any advice? (P.S. I know this can be achieved in a bullet chart but IMO this is more visually appealing for me audience.)

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @thampton

Workaround:

I make a copy of "Sheet6" as "Sheet7", in "Sheet7", select "Tasks Needed" and "Tasks Completed" columns, then "Unpivot columns",

6.png7.png

Close &&Apply, create a measure in "Sheet7",

Measure =
VAR percentage =
    CALCULATE (
        SUM ( Sheet7[Value] ),
        FILTER (
            ALL ( Sheet7 ),
            Sheet7[Label ] = MAX ( Sheet7[Label ] )
                && Sheet7[Attribute] = "Tasks Completed"
        )
    )
        / CALCULATE (
            SUM ( Sheet7[Value] ),
            FILTER (
                ALL ( Sheet7 ),
                Sheet7[Label ] = MAX ( Sheet7[Label ] )
                    && Sheet7[Attribute] = "Tasks Needed"
            )
        )
RETURN
    IF ( MAX ( Sheet7[Attribute] ) = "Tasks Completed", percentage, 1 - percentage )

Select data format for this measure as "percentage",

Add columns and measures from Sheet7 in the "Stacked bar chart" as below

 

8.png

 

Best Regards

Maggie

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @thampton

Workaround:

I make a copy of "Sheet6" as "Sheet7", in "Sheet7", select "Tasks Needed" and "Tasks Completed" columns, then "Unpivot columns",

6.png7.png

Close &&Apply, create a measure in "Sheet7",

Measure =
VAR percentage =
    CALCULATE (
        SUM ( Sheet7[Value] ),
        FILTER (
            ALL ( Sheet7 ),
            Sheet7[Label ] = MAX ( Sheet7[Label ] )
                && Sheet7[Attribute] = "Tasks Completed"
        )
    )
        / CALCULATE (
            SUM ( Sheet7[Value] ),
            FILTER (
                ALL ( Sheet7 ),
                Sheet7[Label ] = MAX ( Sheet7[Label ] )
                    && Sheet7[Attribute] = "Tasks Needed"
            )
        )
RETURN
    IF ( MAX ( Sheet7[Attribute] ) = "Tasks Completed", percentage, 1 - percentage )

Select data format for this measure as "percentage",

Add columns and measures from Sheet7 in the "Stacked bar chart" as below

 

8.png

 

Best Regards

Maggie

This is awesome! Thanks

Ashish_Mathur
Super User
Super User

Hi,

 

Try this measure

 

Progress (%) =SUM(Data[Tasks Completed])/SUM(Data[Tasks Needed])

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

Given the information provided, I'm not following why you are getting a 15 instead of 10. You can display a % of total by clicking the little drop down next to the column or measure in the fields area under VISUALIZATIONS and choose Show Value As | Percentage of Grand Total



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Here is a better example. I am using the 100% stacked column chart (sorry i misspoke in title). 

 

 

I have two values: one value is the "needed" at 784, one value is the "completed" at 64.

 

The data label inside the "completed" is 7.55% which is wrong. It is using (784+64) as the total instead of using 64/784 = 8.2%.

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.