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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
mazzurri
Regular Visitor

Stacked Bar Graph from time duration column

I am currently capturing my team's  daily activity. I have a query for time duration of each activity (end time - start time). Right now I am plotting total duration (00:00 - 23:59). I would like to filter so that I have duration from 00:00 - 11:59 as the day shift and 12:00 to 23:59 as the night shift. I would like them to be stacked bar graphs as well. Would someone be able to provide me insight on how to go about solving this?

Capture.PNG

 

The bar graph is currently showing total duration and the line graph is showing total logged ticket count for the day. I would like to be able to filter them for the day/night shift and have them on the same graph.

 

Thank you

 

Mario

1 ACCEPTED SOLUTION

hi @mazzurri 

For your case, you could try this way:

Create two day /night measure for Duration and  two day /night measure for Ticket Count

For example:

DAY shift Duration = CALCULATE(SUM('Table 1'[Duration]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="DAY shift" ))
Night shift Duration = CALCULATE(SUM('Table 1'[Duration]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Night shift" ))
 
Day shift Ticket Count = CALCULATE(SUM('Table 1'[Ticket Count]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Day shift" ))
Night shift Ticket Count = CALCULATE(SUM('Table 1'[Ticket Count]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Night shift" ))
 
Then put these measrue into visual
Result:
BeforeBeforeAfterAfter
 
and here is sample pbix file, please try it.
 
Regards,
Lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
sturlaws
Resident Rockstar
Resident Rockstar

Hi, @mazzurri 

 

without knowing your data, I can only do an estimated guess on what may solve your problem:

create a new calculated like this:

column =
IF (
    table[start time] >= TIME ( 0, 0, 0 )
        && table[start time] <= TIME ( 11, 59, 0 ),
    "Day shift",
    "Night shift"
)

 

It seems like you are quite new here in the forum, welcome. Here is a link to a post with a lot of tips for how to getting high quality answers when you post in this forum: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Thank you! That helps in getting a "shift" filter on my plot, but how would I plot them both on the same bar/line graph? I would like 2 lines (1 for day and 1 for night) and a stacked bar graph for duration (day and night stacked on each other).

 

Capture2.PNG

hi @mazzurri 

For your case, you could try this way:

Create two day /night measure for Duration and  two day /night measure for Ticket Count

For example:

DAY shift Duration = CALCULATE(SUM('Table 1'[Duration]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="DAY shift" ))
Night shift Duration = CALCULATE(SUM('Table 1'[Duration]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Night shift" ))
 
Day shift Ticket Count = CALCULATE(SUM('Table 1'[Ticket Count]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Day shift" ))
Night shift Ticket Count = CALCULATE(SUM('Table 1'[Ticket Count]),FILTER('Table 1','Table 1'[SHIFTCOLUMN]="Night shift" ))
 
Then put these measrue into visual
Result:
BeforeBeforeAfterAfter
 
and here is sample pbix file, please try it.
 
Regards,
Lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much! That worked perfectly!

 

Mario

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.