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
Anonymous
Not applicable

Calculate Uptime/Down time with multiple overlapping periods

I have been struggling to find the solution for this calculation.

I have data something like this 

sivanjali_0-1615360130564.png



And my output and expected output is 

sivanjali_1-1615360211007.png

If I don't select anything from Type slicer it should return all the dates with Downtime which should not be morethan 24 hours in expected output but I am getting 

sivanjali_2-1615360712273.png



Is there any solution for this with Measures? So I can able to slice my data and get th accurate values in visuals.


 Here is sample .pbix file.  https://drive.google.com/file/d/19XcxqyJcBxQy1mZSop4_cF1iEEGm61pJ/view?usp=sharing

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

This is the overall process:

Here are the steps you can follow:

1. Create Calendar

Date = CALENDARAUTO()

2. Create calculated column.

Date1 = [Date]-0

v-yangliu-msft_0-1616570414032.png

3. Create measure.

Flag =
var _min=MINX(ALLSELECTED(UpTime),[Start])
var _max=MAXX(ALLSELECTED(UpTime),[End])
return
IF(MAX('Date'[Date1])>=_min-1&&MAX('Date'[Date1])<=_max,1,0)

4. Place it in Filter, set is=1, applyfilter

v-yangliu-msft_1-1616570414049.png

5. Create measure.

DownTime (hrs2) =
var _date=CALCULATE(MAX('Date'[Date1]),FILTER(ALL('Date'),[Date1]=DATE(YEAR(MAX([End])),MONTH(MAX([End])),DAY(MAX([End])))))
var _datetable=UNION(SELECTCOLUMNS('UpTime',"1",[Start]),SELECTCOLUMNS('UpTime',"1",[End]))
var _currentdate=MAXX(FILTER(_datetable,YEAR([1])=YEAR(MAX('Date'[Date1]))&&MONTH([1])=MONTH(MAX('Date'[Date1]))&&DAY([1])=DAY(MAX('Date'[Date1]))),[1])
return
ABS(DATEDIFF(_date,_currentdate,SECOND)/3600)

6. Result.

 

v-yangliu-msft_2-1616570414050.png

You can downloaded PBIX file from here.

 

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

This is the overall process:

Here are the steps you can follow:

1. Create Calendar

Date = CALENDARAUTO()

2. Create calculated column.

Date1 = [Date]-0

v-yangliu-msft_0-1616570414032.png

3. Create measure.

Flag =
var _min=MINX(ALLSELECTED(UpTime),[Start])
var _max=MAXX(ALLSELECTED(UpTime),[End])
return
IF(MAX('Date'[Date1])>=_min-1&&MAX('Date'[Date1])<=_max,1,0)

4. Place it in Filter, set is=1, applyfilter

v-yangliu-msft_1-1616570414049.png

5. Create measure.

DownTime (hrs2) =
var _date=CALCULATE(MAX('Date'[Date1]),FILTER(ALL('Date'),[Date1]=DATE(YEAR(MAX([End])),MONTH(MAX([End])),DAY(MAX([End])))))
var _datetable=UNION(SELECTCOLUMNS('UpTime',"1",[Start]),SELECTCOLUMNS('UpTime',"1",[End]))
var _currentdate=MAXX(FILTER(_datetable,YEAR([1])=YEAR(MAX('Date'[Date1]))&&MONTH([1])=MONTH(MAX('Date'[Date1]))&&DAY([1])=DAY(MAX('Date'[Date1]))),[1])
return
ABS(DATEDIFF(_date,_currentdate,SECOND)/3600)

6. Result.

 

v-yangliu-msft_2-1616570414050.png

You can downloaded PBIX file from here.

 

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.

v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous  ,

Here are the steps you can follow:

1. Create Calendar

Date = CALENDARAUTO()

2. Create calculated column.

Date1 = [Date]-0

v-yangliu-msft_0-1615534634285.png

3. Create measure.

Flag =
var _min=MINX(ALLSELECTED(UpTime),[Start])
var _max=MAXX(ALLSELECTED(UpTime),[End])
return
IF(MAX('Date'[Date1])>=_min-1&&MAX('Date'[Date1])<=_max,1,0)

4. Place it in Filter, set is=1, applyfilter

v-yangliu-msft_1-1615534634289.png

5. Result:

v-yangliu-msft_2-1615534634292.png

You can downloaded PBIX file from here.

In your data, 2020.8.25 is 20.1 and 2020.8.26 is 23.5. How is this calculated?

 

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.

Anonymous
Not applicable

Hi @v-yangliu-msft  Thanks for your time.

I have only one record for type 0. Tis Down time started on 8/25/2020 3:50:02 AM and Ended on 8/26/2020 11:26:51 PM. My total down time for this type 0 record is 43:61 hours. But when I am representing it by date wise this should be split in to 20:1 hr and 23:5 on 8/25/2020 & 8/26/2020 respectively. Actually this is my expected out put. 

sivanjali_0-1615622274587.png


I have more records in the type slicers not only 0 and 1. So my expected output should be change as per my type selection which is similar to my above explanation.

I've tried those steps which you provided above but not giving me the expected output. Can you provide me some solution which should give the Expected Output.

 

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.