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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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