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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cottrera
Post Prodigy
Post Prodigy

DAX- IF Statement and Date Columns with days added

Hi 

 

I have the following tables.

 
FACT
RefTeamDue DateCompletion Date
1Emergency12/12/202323/12/2023
2Emergency23/12/202301/01/2024
3Urgent01/12/202317/01/2024
4Routine01/01/202404/01/2024
5Urgent04/01/202417/01/2024
6Emergency04/01/202402/02/2024
7Routine01/01/202415/01/2024
8Routine17/01/202404/02/2024
9Urgent15/01/202404/02/2024
10Urgent17/01/202403/02/2024

 

And a calendar table with the following

DateDayIs_HolidayIs_Weekend
05/02/2024Mon00
06/02/2024Tue00
07/02/2024Wed00
08/02/2024Thu00
09/02/2024Fri00
10/02/2024Sat01
11/02/2024Sun01

 

I have a measure similar to this

SLA =IF(RepairsCoreRR[Date Completed] > = RepairsCoreRR[Due Date] , TRUE() , FALSE())

Our business is trying to see how the SLA would look if the Due Dates were extended by a set abount of days. These new due dates would be different depending on the Team for example
 
 
TeamTir 1Tir 2
Emergency= Due Date + 1= Due Date + 2
Urgent= Due Date + 10= Due Date + 20
Routine= Due Date + 20= Due Date + 40

 

Ineed help creating two DAX measures called Tir 1 and Tir 2 applying this logic

SLA =IF(RepairsCoreRR[Date Completed] > = RepairsCoreRR[Due Date] , TRUE() , FALSE())

Possibly using a SWITCH function that check for the Team and then applied the added number of days to the due date before carrying out the IF function.

 

Some added complexity is that the  dded number of days to the due date must be working days , which can come from the calendar table

thank you RIchard

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cottrera 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"calendar"

vnuocmsft_1-1707193723861.png

 

"FACT"

vnuocmsft_0-1707193617001.png

 

Create measures. You can use NETWORKDAYS to filter working days.

 

Due_Date_1 = 
var _work = NETWORKDAYS(MIN('FACT'[Due Date]), MAX('FACT'[Due Date]))
var _team = SELECTEDVALUE('FACT'[Team])
VAR _DATE=MAX('FACT'[Due Date])
var New_due_1 = IF(_work = 1,
    SWITCH(
        _team,
    "Emergency",_DATE+1,
    "Urgent", _DATE+10,
    "Routine", _DATE+20
    ),
    BLANK()
)
RETURN New_due_1

 

Due_Date_2 = 
var _work = NETWORKDAYS(MIN('FACT'[Due Date]), MAX('FACT'[Due Date]))
var _team = SELECTEDVALUE('FACT'[Team])
VAR _DATE=MAX('FACT'[Due Date])
var New_due_2 = IF(_work = 1,
    SWITCH(
        _team,
    "Emergency",_DATE+2,
    "Urgent", _DATE+20,
    "Routine", _DATE+40
    ),
    BLANK()
)

RETURN New_due_2

 

vnuocmsft_3-1707194156953.png

 

vnuocmsft_4-1707194263891.png

 

Tri1 = IF(SELECTEDVALUE('FACT'[Completion Date]) >= [Due_Date_1], TRUE(), FALSE())

 

Tri2 = IF(SELECTEDVALUE('FACT'[Completion Date]) >= [Due_Date_2], TRUE(), FALSE())

 

Here is the result.

vnuocmsft_5-1707194333554.png

 

Regards,

Nono Chen

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 @cottrera 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"calendar"

vnuocmsft_1-1707193723861.png

 

"FACT"

vnuocmsft_0-1707193617001.png

 

Create measures. You can use NETWORKDAYS to filter working days.

 

Due_Date_1 = 
var _work = NETWORKDAYS(MIN('FACT'[Due Date]), MAX('FACT'[Due Date]))
var _team = SELECTEDVALUE('FACT'[Team])
VAR _DATE=MAX('FACT'[Due Date])
var New_due_1 = IF(_work = 1,
    SWITCH(
        _team,
    "Emergency",_DATE+1,
    "Urgent", _DATE+10,
    "Routine", _DATE+20
    ),
    BLANK()
)
RETURN New_due_1

 

Due_Date_2 = 
var _work = NETWORKDAYS(MIN('FACT'[Due Date]), MAX('FACT'[Due Date]))
var _team = SELECTEDVALUE('FACT'[Team])
VAR _DATE=MAX('FACT'[Due Date])
var New_due_2 = IF(_work = 1,
    SWITCH(
        _team,
    "Emergency",_DATE+2,
    "Urgent", _DATE+20,
    "Routine", _DATE+40
    ),
    BLANK()
)

RETURN New_due_2

 

vnuocmsft_3-1707194156953.png

 

vnuocmsft_4-1707194263891.png

 

Tri1 = IF(SELECTEDVALUE('FACT'[Completion Date]) >= [Due_Date_1], TRUE(), FALSE())

 

Tri2 = IF(SELECTEDVALUE('FACT'[Completion Date]) >= [Due_Date_2], TRUE(), FALSE())

 

Here is the result.

vnuocmsft_5-1707194333554.png

 

Regards,

Nono Chen

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

Thanks for your quick response Nono Chen. Your code works fine.

 

Richard

 

lbendlin
Super User
Super User

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.