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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saanah2019
Helper II
Helper II

Calculate free time

Hi, I have an appointment table and I want to find out the times between appointments and the time there is no appointment. So I have date, datetime, starttime, endtime, duration and I want to declare a total time daily of allowable appointments of 8 hours. I think the easiest way to achieve this is to create a new column and then have it look at each day, add the duration and subtract this sum from the 8 hours and the end result would be my time between appointments.

 

datestartend datetimeduration daily appoint allowed total daily duration free time(daily - total daily duration)
1/1/201810:0010:301/1/2018 10:0030 480 115  365  
1/1/201810:4011:001/1/2018 10:3030         
1/1/201811:05121/1/2018 11:0555         
1/4/201811:0011:301/4/2018 11:0030 480 90  390  
1/4/201811:4012:401/4/2018 11:4060         
1/6/201811:00121/6/2018 11:0060 480 60  420  
1/7/201811:0011:501/7/2018 11:0050 480 150     
1/7/201812:0012:201/7/2018 12:0020         
1/7/201812:301:001/7/2018 12:3030         
1/7/201813:0513:551/7/2018  13:05:00 PM50         
              
              
              

 

 

So I have all the columns except for the last three and want to know how to achieve them in Power BI. Thank you. 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @saanah2019 ,

Do you want to get the output below?

Capture.PNG

If so, please create the calculated columns with the formulas below.

daily appoint allowed = 8*60
total daily duration = CALCULATE(SUM(Table1[duration]),ALLEXCEPT(Table1,'Table1'[date]))
free time = 'Table1'[daily appoint allowed]-'Table1'[total daily duration]

If you still need help, please feel free to ask.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
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

2 REPLIES 2
saanah2019
Helper II
Helper II

@v-piga-msft just a quick add. what happens when there is another column and I also need to take that into consideraton.So now I would want to basically look at the names, if they are the same then look at the date, and then for all the same date sum the duration

 

               
               
namedatestartend datetimeduration daily appoint allowed total daily duration free time(daily - total daily duration)
sam1/1/201810:0010:301/1/2018 10:0030 480 60  420  
sam1/1/201810:4011:001/1/2018 10:3030   60  420  
kate1/1/201811:05121/1/2018 11:0555 480 55  425  
sam1/4/201811:0011:301/4/2018 11:0030 480 90  390  
sam1/4/201811:4012:401/4/2018 11:4060   90  390  
kate1/6/201811:00121/6/2018 11:0060 480 60  420  
kate1/7/201811:0011:501/7/2018 11:0050 480 70  410  
kate1/7/201812:0012:201/7/2018 12:0020   70  410  
sam1/7/201812:301:001/7/2018 12:3030 480 80  400  
sam1/7/201813:0513:551/7/2018  13:05:00 PM50   80  400  
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @saanah2019 ,

Do you want to get the output below?

Capture.PNG

If so, please create the calculated columns with the formulas below.

daily appoint allowed = 8*60
total daily duration = CALCULATE(SUM(Table1[duration]),ALLEXCEPT(Table1,'Table1'[date]))
free time = 'Table1'[daily appoint allowed]-'Table1'[total daily duration]

If you still need help, please feel free to ask.

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.