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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Create stacked bar chart with different categories based on time intervals

Hello everyone,

 

I have a data set that shows me the duration of a call, time the call ended, date of the call, day of the week of the call as pictured below:

 

image.png

My goal is to create a stacked bar chart that splits each call into 2 categories: during work hours (7am-5pm Mon-Fri) and outside working hours (5pm-7am Mon-Fri, all day Sat-Sun). I was thinking of creating a new column in the Power Query editor with a True/False data type to see if each call is under working hours or not. I'm not sure however what the best way of doing it, or if I should do a measure instead.

 

Please let me know if you have any thoughts. Thank you!

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

Hello @Anonymous ,

Try adding this as a calculated column in your table. 

Test =
IF (
    WEEKDAY ( Table1[Call Date] ) IN { 1, 7 } ||
        NOT (
            Table1[Call End Time (MST)] > TIME ( 8, 0, 0 )
                && Table1[Call End Time (MST)] < TIME ( 17, 0, 0 )
        ),
    "Out",
    "In"
)

View solution in original post

XLBob
Resolver II
Resolver II

I'd like to add all my custom columns inside Power Query if possible.

so you can do this

if (Date.DayOfWeek([Call Date],Day.Monday)<5 and (Time.Hour([Call End Time])>=7 and Time.Hour([Call End Time])<=17))then 1 else 0

and this is what you will get

Capture.JPG

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks guys, either solution works and does what I was looking for.

XLBob
Resolver II
Resolver II

I'd like to add all my custom columns inside Power Query if possible.

so you can do this

if (Date.DayOfWeek([Call Date],Day.Monday)<5 and (Time.Hour([Call End Time])>=7 and Time.Hour([Call End Time])<=17))then 1 else 0

and this is what you will get

Capture.JPG

 

jdbuchanan71
Super User
Super User

Hello @Anonymous ,

Try adding this as a calculated column in your table. 

Test =
IF (
    WEEKDAY ( Table1[Call Date] ) IN { 1, 7 } ||
        NOT (
            Table1[Call End Time (MST)] > TIME ( 8, 0, 0 )
                && Table1[Call End Time (MST)] < TIME ( 17, 0, 0 )
        ),
    "Out",
    "In"
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors