Hello @cms418,
With regards to your first query, you need to enter the context into the measure as per your business specific requirements i.e. whether you want to consider blanks end dates into the calculation or not. If so, what will be the condition? Blank end dates will be considered as Today? Or Blank end dates will be taken as start date itself? Or if it’s blank then ignore by putting the condition as 0? "I leave that aspect upto you about how you want to approach."
In my current measure, I’ll be considering the blank end dates as the start date itself.
Below is the measure provided for the reference -
Working Days =
----- Mobilization Calculation -----
VAR _Mobilization =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Mobilization Start Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) )
----- Site Access Calculation -----
VAR _Site_Access =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Site Access End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Access Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Access Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) = SELECTEDVALUE( Data[Actual Site Access Start Date] ) &&
SELECTEDVALUE( Data[Actual Mobilization End Date] ) = SELECTEDVALUE( Data[Actual Site Access End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) = SELECTEDVALUE( Data[Actual Site Access Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Access Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Access End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Mobilization Start Date] ) >= SELECTEDVALUE( Data[Actual Site Access Start Date] ) &&
SELECTEDVALUE( Data[Actual Mobilization End Date] ) <= SELECTEDVALUE( Data[Actual Site Access End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Access Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Access End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Mobilization ,
IF(
SELECTEDVALUE( Data[Actual Mobilization End Date] ) = SELECTEDVALUE( Data[Actual Site Access End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Access Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Access End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Site Preparation Calculation -----
VAR _Site_Preparation =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Site Access Start Date] ) = SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) &&
SELECTEDVALUE( Data[Actual Site Access End Date] ) = SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Site Access Start Date] ) = SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Site Access Start Date] ) >= SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) &&
SELECTEDVALUE( Data[Actual Site Access End Date] ) <= SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Site_Access ,
IF(
SELECTEDVALUE( Data[Actual Site Access End Date] ) = SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) ,
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Excavation Calculation -----
VAR _Excavation =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Excavation End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Excavation Start Date] ) ,
SELECTEDVALUE( Data[Actual Excavation Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) = SELECTEDVALUE( Data[Actual Excavation Start Date] ) &&
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) = SELECTEDVALUE( Data[Actual Excavation End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) = SELECTEDVALUE( Data[Actual Excavation Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Excavation Start Date] ) ,
SELECTEDVALUE( Data[Actual Excavation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Site Preparation Start Date] ) >= SELECTEDVALUE( Data[Actual Excavation Start Date] ) &&
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) <= SELECTEDVALUE( Data[Actual Excavation End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Excavation Start Date] ) ,
SELECTEDVALUE( Data[Actual Excavation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Site_Preparation ,
IF(
SELECTEDVALUE( Data[Actual Site Preparation End Date] ) = SELECTEDVALUE( Data[Actual Excavation End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Excavation Start Date] ) ,
SELECTEDVALUE( Data[Actual Excavation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Initial Coating Calculation -----
VAR _Initial_Coating_Inspection =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Excavation Start Date] ) = SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) &&
SELECTEDVALUE( Data[Actual Excavation End Date] ) = SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Excavation Start Date] ) = SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Excavation Start Date] ) >= SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) &&
SELECTEDVALUE( Data[Actual Excavation End Date] ) <= SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Excavation ,
IF(
SELECTEDVALUE( Data[Actual Excavation End Date] ) = SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) ,
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Pipe Prep Calculation -----
VAR _Pipe_Prep =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ,
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) = SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) &&
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) = SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) = SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ,
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Initial Coating Inspection Start Date] ) >= SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) &&
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) <= SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ,
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Initial_Coating_Inspection ,
IF(
SELECTEDVALUE( Data[Actual Initial Coating Inspection End Date] ) = SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) ,
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- NDE Asmt Calculation -----
VAR _NDE_Asmt =
IF( ISBLANK( SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) = SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) &&
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) = SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) >= SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) &&
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) <= SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Pipe_Prep ,
IF(
SELECTEDVALUE( Data[Actual Pipe Prep Start Date] ) = SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Pipe Prep End Date] ) = SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Repair Calculation -----
VAR _Repair =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Repair End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Repair Start Date] ) ,
SELECTEDVALUE( Data[Actual Repair Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) = SELECTEDVALUE( Data[Actual Repair Start Date] ) &&
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) = SELECTEDVALUE( Data[Actual Repair End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) = SELECTEDVALUE( Data[Actual Repair Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Repair Start Date] ) ,
SELECTEDVALUE( Data[Actual Repair End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual NDE Asmt. Start Date] ) >= SELECTEDVALUE( Data[Actual Repair Start Date] ) &&
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) <= SELECTEDVALUE( Data[Actual Repair End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Repair Start Date] ) ,
SELECTEDVALUE( Data[Actual Repair End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _NDE_Asmt ,
IF(
SELECTEDVALUE( Data[Actual NDE Asmt. End Date] ) = SELECTEDVALUE( Data[Actual Repair End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Repair Start Date] ) ,
SELECTEDVALUE( Data[Actual Repair End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Post Repair Calculation -----
VAR _Post_Repair_Asmt =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Repair Start Date] ) = SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) &&
SELECTEDVALUE( Data[Actual Repair End Date] ) = SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Repair Start Date] ) = SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Repair Start Date] ) >= SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) &&
SELECTEDVALUE( Data[Actual Repair End Date] ) <= SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Repair ,
IF(
SELECTEDVALUE( Data[Actual Repair End Date] ) = SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) ,
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Recoat Calculation -----
VAR _Recoat =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Recoat End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Recoat Start Date] ) ,
SELECTEDVALUE( Data[Actual Recoat Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) = SELECTEDVALUE( Data[Actual Recoat Start Date] ) &&
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) = SELECTEDVALUE( Data[Actual Recoat End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) = SELECTEDVALUE( Data[Actual Recoat Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Recoat Start Date] ) ,
SELECTEDVALUE( Data[Actual Recoat End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Post Repair Asmt. Start Date] ) >= SELECTEDVALUE( Data[Actual Recoat Start Date] ) &&
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) <= SELECTEDVALUE( Data[Actual Recoat End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Recoat Start Date] ) ,
SELECTEDVALUE( Data[Actual Recoat End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Post_Repair_Asmt ,
IF(
SELECTEDVALUE( Data[Actual Post Repair Asmt. End Date] ) = SELECTEDVALUE( Data[Actual Recoat End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Recoat Start Date] ) ,
SELECTEDVALUE( Data[Actual Recoat End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Backfill Calculation -----
VAR _Backfill =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Backfill End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Backfill Start Date] ) ,
SELECTEDVALUE( Data[Actual Backfill Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Recoat Start Date] ) = SELECTEDVALUE( Data[Actual Backfill Start Date] ) &&
SELECTEDVALUE( Data[Actual Recoat End Date] ) = SELECTEDVALUE( Data[Actual Backfill End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Recoat Start Date] ) = SELECTEDVALUE( Data[Actual Backfill Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Backfill Start Date] ) ,
SELECTEDVALUE( Data[Actual Backfill End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Recoat Start Date] ) >= SELECTEDVALUE( Data[Actual Backfill Start Date] ) &&
SELECTEDVALUE( Data[Actual Recoat End Date] ) <= SELECTEDVALUE( Data[Actual Backfill End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Backfill Start Date] ) ,
SELECTEDVALUE( Data[Actual Backfill End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Recoat ,
IF(
SELECTEDVALUE( Data[Actual Recoat End Date] ) = SELECTEDVALUE( Data[Actual Backfill End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Backfill Start Date] ) ,
SELECTEDVALUE( Data[Actual Backfill End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Cleanup or Remediation Calculation -----
VAR _Cleanup_or_Remediation =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Backfill Start Date] ) = SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) &&
SELECTEDVALUE( Data[Actual Backfill End Date] ) = SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Backfill Start Date] ) = SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Backfill Start Date] ) >= SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) &&
SELECTEDVALUE( Data[Actual Backfill End Date] ) <= SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Backfill ,
IF(
SELECTEDVALUE( Data[Actual Backfill End Date] ) = SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) ,
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Demobilization Calculation -----
VAR _Demobilization =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Demobilization End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) = SELECTEDVALUE( Data[Actual Demobilization Start Date] ) &&
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) = SELECTEDVALUE( Data[Actual Demobilization End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) = SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Cleanup / Remediation Start Date] ) >= SELECTEDVALUE( Data[Actual Demobilization Start Date] ) &&
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) <= SELECTEDVALUE( Data[Actual Demobilization End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Cleanup_or_Remediation ,
IF(
SELECTEDVALUE( Data[Actual Cleanup / Remediation End Date] ) = SELECTEDVALUE( Data[Actual Demobilization End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
----- Mat Demobilization Calculation -----
VAR _Mat_Demobilization =
IF( ISBLANK( SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ,
IF(
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) = SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) &&
SELECTEDVALUE( Data[Actual Demobilization End Date] ) = SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ,
0 ,
IF(
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) = SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - 1 ,
IF(
SELECTEDVALUE( Data[Actual Demobilization Start Date] ) >= SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) &&
SELECTEDVALUE( Data[Actual Demobilization End Date] ) <= SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) - _Demobilization ,
IF(
SELECTEDVALUE( Data[Actual Demobilization End Date] ) = SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ,
0 ,
CALCULATE( COUNTROWS( Dates ) ,
DATESBETWEEN(
Dates[Date] ,
SELECTEDVALUE( Data[Actual Mat Demobilization Start Date] ) ,
SELECTEDVALUE( Data[Actual Mat Demobilization End Date] ) ) ,
Dates[DayOfWeekName] <> "Sunday" ,
ALLSELECTED( Data ) ) ) ) ) ) )
RETURN
_Mobilization + _Site_Access + _Site_Preparation + _Excavation + _Initial_Coating_Inspection + _Pipe_Prep + _NDE_Asmt + _Repair + _Post_Repair_Asmt + _Recoat + _Backfill + _Cleanup_or_Remediation + _Demobilization + _Mat_Demobilization
Once you write the above measure, you’ll see that overlapping is ignored. Below is the screenshot of the final results provided for the reference purposes.
I’m also attaching the working of the PBIX file for the reference purposes.
Thanks and Warm Regards,
Harsh
Date Stuff4 - Harsh.pbix (96.4 KB)
Dig-0057 - Harsh.xlsx (14.2 KB)