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

Calculate number of days in period excluding during MCO Period Start MCO and End MCO

Hi all

I'm struggling with a way to calculate the number of days excluding the MCO period.  If the incurred date and Resolved date is between the MCO period how many days are there in that period.
The cycle time exclude the MCO is the days that counted exluding the period of MCO

Anyone can help me on this ?
here is the attach for your reference.

 

Thanks

MCO Start01/06/2021    
MCO End01/09/2021    
Last date before MCO31/05/2021    
      
StatusCycle TimeIncurredResolvedDays in MCO 3.0Cycle Time Exclude MCO 3.0
Ticket Closed5523/04/202116/06/20211639
Ticket Closed1194/23/20218/19/20218039
Ticket Closed1194/23/20218/19/20218039
Ticket Closed1194/23/20218/19/20218039


Example.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Not very clear about this——how can i calculate using the queries for Days in MCO without hardcode in excel

For your original post, I have done it in Power BI using DAX.

 

Firstly, as @johnt75 mentioned , you may need a Date table for slicers/filters to set the Start and End date for MCO status. For example:

MCO Dates = CALENDAR(DATE(2021,1,1),DATE(2021,12,31)) 

Then create measures:

Cycle Time = DATEDIFF(MAX('Table'[Incurred]),MAX('Table'[Resolved]),DAY)+1
Days in MCO = 
var _start=IF(MIN('MCO Dates'[Date])>MAX('Table'[Incurred]),MIN('MCO Dates'[Date]),MAX('Table'[Incurred]))
var _end=IF(MAX('MCO Dates'[Date])<MAX('Table'[Resolved]),MAX('MCO Dates'[Date]),MAX('Table'[Resolved]))
return DATEDIFF(_start,_end,DAY)+1
Cycle Time Exclude MCO = [Cycle Time] -[Days in MCO] 

Output:

Eyelyn9_0-1649140552062.png

Best Regards,
Eyelyn Qin
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
Anonymous
Not applicable

Hi @Anonymous ,

 

Not very clear about this——how can i calculate using the queries for Days in MCO without hardcode in excel

For your original post, I have done it in Power BI using DAX.

 

Firstly, as @johnt75 mentioned , you may need a Date table for slicers/filters to set the Start and End date for MCO status. For example:

MCO Dates = CALENDAR(DATE(2021,1,1),DATE(2021,12,31)) 

Then create measures:

Cycle Time = DATEDIFF(MAX('Table'[Incurred]),MAX('Table'[Resolved]),DAY)+1
Days in MCO = 
var _start=IF(MIN('MCO Dates'[Date])>MAX('Table'[Incurred]),MIN('MCO Dates'[Date]),MAX('Table'[Incurred]))
var _end=IF(MAX('MCO Dates'[Date])<MAX('Table'[Resolved]),MAX('MCO Dates'[Date]),MAX('Table'[Resolved]))
return DATEDIFF(_start,_end,DAY)+1
Cycle Time Exclude MCO = [Cycle Time] -[Days in MCO] 

Output:

Eyelyn9_0-1649140552062.png

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

johnt75
Super User
Super User

Assuming that you have a date table and slicer tables for the MCO start & end dates, you could create a measure like

Cycle Time excluding MCO =
var MCOStartDate = SELECTEDVALUE( 'MCO Start Date'[Date])
var MCOEndDate = SELECTEDVALUE( 'MCO End Date'[Date])
var datesToCount = EXCEPT( 
   DATESBETWEEN( 'Date'[Date], SELECTEDVALUE('Table'[Incurred]), SELECTEDVALUE('Table'[Resolved]),
   DATESBETWEEN('Date'[Date], MCOStartDate, MCOEndDate)
)
return COUNTROWS(datesToCount)
Anonymous
Not applicable

for 

how can i calculate using the queries for Days in MCO without hardcode in excel

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