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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
iamblue91
Frequent Visitor

Another 100% Stacked Bar Chart Question

Hi all! 

Really beginner question, so I apologize. 

 

I'm trying to sort Task Type as a share of % of an employee's total time for the month. The current issue is in the image attached -- each person just has a count of tasks and a sum of hours. Assume that Employee A spent 25% of their time on each Administration, Research, Writing, and Meetings. I want to show the 25% share of each. 

 

We use Harvest to track our time, which is downloaded to an Excel file. The way the data is exported is based on each person's time per day per task (based on project, but I'm not worried about that right now). I've provided an example of what this would look like. 

DateClientProjectTaskHoursBillableNameBillable AmountCost Amount
 TeslaBatteryAdmin4 

Bob

  
 TeslaBatteryMeetings4 Joe   
 TeslaBatteryWriting4 Joe   
 TeslaBatteryResearch4 Joe   

 

I have a feeling that I have to implement some DAX....? (I'm VERY new to using PowerBI and DB query writing, though I am somewhat comfortable in Excel)

PowerBI for posting.png

 

 

 

 

1 ACCEPTED SOLUTION
dearwatson
Continued Contributor
Continued Contributor

Hi iamblue,

 

Welcome to the revolution 🙂

 

there are ways to do this without DAX but if you want to use PowerBI in any meaningful way you'll need DAX... and this is a good one to get started on:

 

First we make an easy measure: SUM of Hours (in this case the column Table1[Hours]) - this is already being done for you automatically in your graph but we create an "Explicit Measure" because we should NEVER use implicit measures according to the gurus of DAX.

 

create a measure:

Total Hours = SUM(Table1[Hours])

 

Now we use DAX magic to give us a measure that will always return the TOTAL hours even if we filter it...

We'll call it a Grand Total.

Grand Total Hours = CALCULATE([Total Hours],ALL(Table1)) -- this uses CALCULATE to remove the filters with the ALL function.

 

so the percentage calculation is:

Perc of Total Hours = DIVIDE([Total Hours], [Grand Total Hours],0)

 

Add the "perc of Total Hours Measure" as the Value in the 100% stack. Person Name in Axis, Activity in Legend... DONE.

 

Now that you learned the DAX way here's the 2 second no DAX solution:

=============================

Create blank 100% stacked bar graph

drag Hours to Value (<-- this defaults to an Implicit SUM so you really should create a measure)

drag Name to Axis

drag Activity to Legend

In the Visualizations pane click the little down arrow next to "Hours"

select Quick Calc->Show Value as Percent of Grand Total

Capture.PNG

 

Viola!

 

Capture.PNG

 

That should do it...

 

View solution in original post

4 REPLIES 4
dearwatson
Continued Contributor
Continued Contributor

Hi iamblue,

 

Welcome to the revolution 🙂

 

there are ways to do this without DAX but if you want to use PowerBI in any meaningful way you'll need DAX... and this is a good one to get started on:

 

First we make an easy measure: SUM of Hours (in this case the column Table1[Hours]) - this is already being done for you automatically in your graph but we create an "Explicit Measure" because we should NEVER use implicit measures according to the gurus of DAX.

 

create a measure:

Total Hours = SUM(Table1[Hours])

 

Now we use DAX magic to give us a measure that will always return the TOTAL hours even if we filter it...

We'll call it a Grand Total.

Grand Total Hours = CALCULATE([Total Hours],ALL(Table1)) -- this uses CALCULATE to remove the filters with the ALL function.

 

so the percentage calculation is:

Perc of Total Hours = DIVIDE([Total Hours], [Grand Total Hours],0)

 

Add the "perc of Total Hours Measure" as the Value in the 100% stack. Person Name in Axis, Activity in Legend... DONE.

 

Now that you learned the DAX way here's the 2 second no DAX solution:

=============================

Create blank 100% stacked bar graph

drag Hours to Value (<-- this defaults to an Implicit SUM so you really should create a measure)

drag Name to Axis

drag Activity to Legend

In the Visualizations pane click the little down arrow next to "Hours"

select Quick Calc->Show Value as Percent of Grand Total

Capture.PNG

 

Viola!

 

Capture.PNG

 

That should do it...

 

Thanks DearWatson! 

 

Glad to be part of it! Thanks for your detailed response -- as for DAX, I intend to learn at least some of the basics so I can grow a bit more as I need more in-depth analysis.

 

I appreaciate you providing both solutions! I'm learning this on my own, and it's good to know there's a community here that I can bounce my questions off of!

 

I'll try the solution tonight and report back!

sebastian_ebg
Helper I
Helper I

You don't actually need DAX, you just need a better understanding of how stacked charts work 🙂

 

Firstly, make sure that the default summarization option under the "Modeling" ribbon on the "Hours" field is set to "Sum" then delete the "Count of tasks" from the Values and finally drag the Tasks Hierarchy or the Task field into Legend. Done!

Thanks! Smiley Happy

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.