Forum Discussion
DAX for Submission KPI
Hi koyDominic
please try
Invoice Submission KPI =
VAR TimeOut = 'Table'[Delivery - Time Out]
VAR MaxDate = TimeOut + 4
VAR Dates =
CALENDAR ( TimeOut, MaxDate )
VAR MaxDate1 =
MAXX ( FILTER ( Dates, WEEKDAY ( [Date], 2 ) = 5 ), [Date] )
VAR MaxDate2 =
MAXX ( FILTER ( Dates, WEEKDAY ( [Date], 2 ) = 2 ), [Date] )
RETURN
SWITCH (
TRUE (),
WEEKDAY ( TimeOut, 2 )
IN { 1, 2, 3, 4 }
&& TimeOut <= MaxDate1, "Compliant",
WEEKDAY ( TimeOut, 2 )
IN { 5, 6, 7 }
&& TimeOut <= MaxDate2, "Compliant",
"None compliant"
)
- koyDominic3 years agoRegular Visitor
Hi tamerj1,
Thank you and I appreciated your help. I tried the above, however all results shows "compliant". I guess the BI calculated based only on the weekdays but did not consider dates. I attached reference picture of the result below. The marked in red are supposed to be non compliant since it failed to submit the invoices before Tuesday (March 28) of the following week. The marked in yellow are correct.
- tamerj13 years ago
Community Champion
koyDominic
Oh! my mistakeInvoice Submission KPI = VAR Submitted = 'Table'[Invoice Submitted] VAR TimeOut = 'Table'[Delivery - Time Out] VAR MaxDate = TimeOut + 4 VAR Dates = CALENDAR ( TimeOut, MaxDate ) VAR MaxDate1 = MAXX ( FILTER ( Dates, WEEKDAY ( [Date], 2 ) = 5 ), [Date] ) VAR MaxDate2 = MAXX ( FILTER ( Dates, WEEKDAY ( [Date], 2 ) = 2 ), [Date] ) RETURN SWITCH ( TRUE (), WEEKDAY ( TimeOut, 2 ) IN { 1, 2, 3, 4 } && Submitted <= MaxDate1, "Compliant", WEEKDAY ( TimeOut, 2 ) IN { 5, 6, 7 } && Submitted <= MaxDate2, "Compliant", "None compliant" )