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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
FlossBI
Regular Visitor

Aggregate/slice hours between two date time values by month

Hi,

 

I've got a table where I'm calculating working hours outage between two date/time stamps from Dataverse.  The durations range from a few hours to a few weeks and can start between 6am and 6pm on any working day and can also start on the hour or 30 minutes past.  I've got a calculated column in DAX that gives me the working hours, but I've realised that where the duration is spanning different months (and potentially financial years) I can't give end users the number of working hours outage in current month and so on.  

 

In this example, there is a start date in October and the end date in November.  Using the month of start date in a table it's giving a total of 182 hours using the DAX calculation - but that's the whole outage duration, not just the hours in October.  

FlossBI_2-1672771562594.png

FlossBI_3-1672771589321.png

But if we could aggregate it by the months it would look more like this:

FlossBI_5-1672771991245.png

 

I thought about using Power Query and listing the individual days between the datetimes but that doesn't work when the duration is only a few hours?  I've tried using power query list.datetimes with an hour interval but that doesn't work for 30 minute past the hour values. I tried 30 min intervals between the two datetimes but I can't seem to get it to work as it won't list everything in the duration for example List.DateTimes([Start], Duration.Days([End] - [Start]), #duration(0,1,30,0)) for the values above returns about 21 rows

FlossBI_6-1672773319949.png

I'm also not sure how I would calculate the working hours in the table with the list like this rather than start and end columns.  Ideally we'd just list the days out rather than the 30 intervals as I'm worried about the size of the table and the calculations when it's a long outage, but as mentioned above that's tricky when it's out for a few hours.

 

I've uploaded the pbix file

https://1drv.ms/u/s!As7wPfxult_enVcuojW02yMTbN7t?e=FdlXtQ

 I would be very grateful for any inspiration or advice please.

2 REPLIES 2
FlossBI
Regular Visitor

Thanks @v-binbinyu-msft 

I have mutiple outage records just with a start datetime and end datetime.  I am measuring the duration between them in working hours.  The duration varies and can last a few hours through to a few weeks.

I would like to give users the outage duration working hours by month and financial year.  But with only the start and end datetime, if the duration spans more than one month for instance I can't work out how to do it.

v-binbinyu-msft
Community Support
Community Support

Hi @FlossBI ,

I'm a little confused about your needs, Could you please explain them further?

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.