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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
dimidi
Regular Visitor

HELP with DAX

Hi DAX Experts. I am working on my first report in Power BI and I am seriosly stucked in a something that for me should be an issue as I have aexperience  as a software developer but with minimal DAX experiance. The problem is:

I have a dataset that have data for Drivers which have the following fields:

  • date (date only - no time component)
  • driver - driver name
  • shift_start - date/time 
  • shift_end - date/time

In report I need to have a line chart that on X-axis have hours of the day (from 0 to 23) and on Y-axis I need to have number of drivers that is on duty (on hourly basis). X axis should display each hour even the count of drivers is 0.

Any helps will be much appreciated

Thanks a lot

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @dimidi ,

 

 

Here are the steps you can follow:

1. Select [Shift_Start] and [Shift_End] - Duplicate Column..

vyangliumsft_0-1697704552886.png

vyangliumsft_1-1697704552890.png

2. Select each of the two copied columns - Time - Time Only.

vyangliumsft_2-1697704574608.png

vyangliumsft_3-1697704574610.png

3. Create calculated table.

Time =
VAR __StartTime= TIME(0,0,0)
var __EndTime= TIME(23,0,0)
var __Duration= TIME(1,0,0)
return
GENERATESERIES(__StartTime,__EndTime,__Duration)

vyangliumsft_4-1697704589686.png

4. Create measure.

Time =
VAR __StartTime= TIME(0,0,0)
var __EndTime= TIME(23,0,0)
var __Duration= TIME(1,0,0)
return
GENERATESERIES(__StartTime,__EndTime,__Duration)

5. Result:

vyangliumsft_5-1697704617912.png

 

Best Regards,

Liu Yang

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

7 REPLIES 7
Anonymous
Not applicable

Hi  @dimidi ,

 

 

Here are the steps you can follow:

1. Select [Shift_Start] and [Shift_End] - Duplicate Column..

vyangliumsft_0-1697704552886.png

vyangliumsft_1-1697704552890.png

2. Select each of the two copied columns - Time - Time Only.

vyangliumsft_2-1697704574608.png

vyangliumsft_3-1697704574610.png

3. Create calculated table.

Time =
VAR __StartTime= TIME(0,0,0)
var __EndTime= TIME(23,0,0)
var __Duration= TIME(1,0,0)
return
GENERATESERIES(__StartTime,__EndTime,__Duration)

vyangliumsft_4-1697704589686.png

4. Create measure.

Time =
VAR __StartTime= TIME(0,0,0)
var __EndTime= TIME(23,0,0)
var __Duration= TIME(1,0,0)
return
GENERATESERIES(__StartTime,__EndTime,__Duration)

5. Result:

vyangliumsft_5-1697704617912.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @Anonymous,

Thank you very much for your help. This is exactly what I need to achieve.

Many thanks again,

Dimitar 

dimidi
Regular Visitor

 

So here is the sample of my dataset

 

DriverDateShift_StartShift_End
John Smith13/09/202313/09/2023 05:30:0013/09/2023 13:00:00
Paul Jones13/09/202313/09/2023 07:00:0013/09/2023 19:00:00
Tom Young13/09/202313/09/2023 12:00:0013/09/2023 20:00:00
Lee Bennett13/09/202313/09/2023 09:00:0013/09/2023 17:00:00
Lee Bennett14/09/202314/09/2023 09:00:0013/09/2023 17:00:00
Stewart Anderson13/09/202313/09/2023 19:00:0014/09/2023 07:00:00

 

and this is the result that I need:

dimidi_0-1697120491460.png

 

dimidi
Regular Visitor

I am really sorry but I can't get this message. For me is absolutely no sense 

edhans
Community Champion
Community Champion

You've not given enough info to allow us to help you. We have no idea what your data looks like, have no sample data, and have no mock up of your goal.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thanks for explaining

edhans
Community Champion
Community Champion

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.