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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
DanielHolland
Frequent Visitor

If Statement

Hi All im after help on this, 

 

Im Reporting on SLAs and need to show the "SLA status" 

 

Please can I have a DAX forumla that will output this? 

 

Here is an example Data set, Status of the ticket. When the fault is to be fixed by, Todays date and Time, If todays date is Past the expected fix date and the ticket is still in open status it needs to show "breach" .

 

StatusExpected fix Date Todays DateSLA Status
Open30/02/2022  14:5228/03/2022 13:05Breach
Open05/04/2022 15:0928/03/2022 13:05On Track
Closed27/03/2022 14:0528/03/2022 13:05HIT

 

Thanks 

Dan

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

This is how you can do it with Power Query.

 

Table.AddColumn(#"Changed Type", "Breach Status", each if [Todays Date] > [#"Expected fix Date "] and [Status] = "Open" then "Breach" else "Not Breach", type text)

 

Sample Script

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i9IzVPSUTIw0jey0DcyMDJSMDSxMjUCCRkjhIytDEyBQk5FqYnJGUqxOgh9JvoGplBFplYGltj1+ecphBQlJmeDdTrn5BenpkAVmsPtBCvEotfDM0QpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, #"Expected fix Date " = _t, #"Todays Date" = _t, #"SLA Status" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Todays Date", type datetime}, {"Expected fix Date ", type datetime}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Breach Status", each if [Todays Date] > [#"Expected fix Date "] and [Status] = "Open" then "Breach" else "Not Breach", type text)
in
    #"Added Custom1"

jennratten_0-1648650094588.png

 

This is how you can do it with DAX:

Breach Status DAX = if(and('Table'[Status] = "Open",'Table'[Expected fix Date ]<'Table'[Todays Date]),"Breach","Not Breach")

 

jennratten_1-1648650264243.png

 

 

View solution in original post

2 REPLIES 2
jennratten
Super User
Super User

This is how you can do it with Power Query.

 

Table.AddColumn(#"Changed Type", "Breach Status", each if [Todays Date] > [#"Expected fix Date "] and [Status] = "Open" then "Breach" else "Not Breach", type text)

 

Sample Script

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i9IzVPSUTIw0jey0DcyMDJSMDSxMjUCCRkjhIytDEyBQk5FqYnJGUqxOgh9JvoGplBFplYGltj1+ecphBQlJmeDdTrn5BenpkAVmsPtBCvEotfDM0QpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, #"Expected fix Date " = _t, #"Todays Date" = _t, #"SLA Status" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Todays Date", type datetime}, {"Expected fix Date ", type datetime}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Breach Status", each if [Todays Date] > [#"Expected fix Date "] and [Status] = "Open" then "Breach" else "Not Breach", type text)
in
    #"Added Custom1"

jennratten_0-1648650094588.png

 

This is how you can do it with DAX:

Breach Status DAX = if(and('Table'[Status] = "Open",'Table'[Expected fix Date ]<'Table'[Todays Date]),"Breach","Not Breach")

 

jennratten_1-1648650264243.png

 

 

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Whatever data you have supplied, you can use following formula

=if([Status]="Open",if([Expected fix Date]<[Todays Date],"Breach","On Track"),"HIT")

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors