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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Using IF Statement on Date-Times Columns to calculate based on Three conditions

I want to use an IF statement to create three conditions based on appointments for bookings.  

I have three columns of times. Created Datetime, Failture datetime and Succeed Date Time.

The calculation must be relative and take account of the actual date of today.

 

The three conditions...

 

1. If succeed datetime is blank and the failure datetime is prior todays date (22/01/2020) then the condition is "Fail"SLA 1.PNG

 

2. if the failture date is ahead of todays date and the succeed datetime is blank then condtion is "Inside SLA"

 

SLA 2.PNG

 

3.  IF the succeed column has a date that is before the failture column then "Pass"

 

SLA 3.png

 

All of these work with the current function

SLA = IF(SLA[Faildate] < today() || SLA[Faildate] < SLA[Succeed], "Fail", IF(ISBLANK(SLA[Succeed]&&(SLA[Fail]>Today())), "Inside" SLA","Pass"))

 

The issue is that the equation doesnt take into account these Cases. These should be passes because the succeed date is eariler than the fail date. 

 

SLA 4.PNG

 

Anyway around this?

 
1 ACCEPTED SOLUTION
JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

I think the problem is in the first part of your if statement. Where you say; IF(SLA[Faildate] < today() || SLA[Faildate] < SLA[Succeed], "Fail". You use an 'or' statement here, so if the the faildate < today (which is the case for you last 4 lines) or faildate<succeed then the SLA status is Fail. 

The Columns SLA2 is your IF statement. SLA3 is showing the expected result (if I am not mistaken)

 

2020-01-22 23_03_43-20200122-2 - Power BI Desktop.png

SLA3 looks like : 

SLA3 = 
switch(
true(),
ISBLANK(SLA[Succeed]) && SLA[FailDate] <TODAY(),"Fail",
ISBLANK(SLA[Succeed]) && SLA[FailDate] >= TODAY(), "Inside SLA",
SLA[Succeed]<=SLA[FailDate], "Pass",
"")

 I think it is easier to read and I hope it helps.

jan

if this is a solution for you, don't forget to mark it as such. thanks

Jan

 

 

View solution in original post

3 REPLIES 3
JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

I think you have an issue with the brackets on the bold part of the statement. Now you are testing if the combination of fields isblank, but you shoul only test if succeed is blank (at least that is what I thoug was the idea.

 

Jan 

Anonymous
Not applicable

Hi  JustJan,

 

Yes added the bracket in for this part 

 

IF(ISBLANK(slakpiinstances[succeededon])&&(slakpiinstances[failuretime]>TODAY()),"Inside SLA",

and it has worked.

 

Thank you

JustJan
Responsive Resident
Responsive Resident

Hi @Anonymous ,

 

I think the problem is in the first part of your if statement. Where you say; IF(SLA[Faildate] < today() || SLA[Faildate] < SLA[Succeed], "Fail". You use an 'or' statement here, so if the the faildate < today (which is the case for you last 4 lines) or faildate<succeed then the SLA status is Fail. 

The Columns SLA2 is your IF statement. SLA3 is showing the expected result (if I am not mistaken)

 

2020-01-22 23_03_43-20200122-2 - Power BI Desktop.png

SLA3 looks like : 

SLA3 = 
switch(
true(),
ISBLANK(SLA[Succeed]) && SLA[FailDate] <TODAY(),"Fail",
ISBLANK(SLA[Succeed]) && SLA[FailDate] >= TODAY(), "Inside SLA",
SLA[Succeed]<=SLA[FailDate], "Pass",
"")

 I think it is easier to read and I hope it helps.

jan

if this is a solution for you, don't forget to mark it as such. thanks

Jan

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.