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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
prasadhebbar315
Advocate I
Advocate I

Condition to proactively predict escalation

Hello everyone,

 

I am working on a solution to identify if ML model predicted escalation before it was escalated.

Data has Serial Number, Escalated Date, Prediction_date, Prediction_Category. Condition to calculate "Prediction_Before_Escalation" is that for a SN, the Prediction_Date should be less than or equal to Escalated Date and the Prediction_Category should be "High or Critical". SN_Prediction_Before_Escalation condition is at least once for a SN, the Prediction_Date should be less than or equal to Escalated Date and the Prediction_Category should be "High or Critical". Please note that Escalation_Date is in a different table and Prediction_Date is in another table. Both tables are related on Serial Number. The IF condition should also specify relationships.

 

In the below table Prediction_Before_Escalation is No for 4642531975 since Prediction_Date is after Escalation Date even though Prediction_Category is High. Also for SN: GM03WRG1 there is one instance of No but the prediction has happened at least once before escalation and hence the last column is marked as Yes. 

For SN: AAE120MP the prediction has happened before escalation but the category is not "High or Critical" hence "No"

serialnumberEscalated_DatePrediction_DatePrediction_CategoryPrediction_Before_EscalationSN_Prediction_Before_Escalation
781273443/23/20233/23/2023CriticalYesYes
781273443/23/20233/21/2023CriticalYesYes
46425319754/24/20234/25/2023HighNoNo
AAE120MP4/11/20234/11/2023ModerateNoNo
AAE120MP4/11/20234/10/2023ModerateNoNo
AAE120MP4/11/20233/31/2023LowNoNo
GM029LQD4/14/20234/14/2023CriticalYesYes
GM03WRG14/12/20234/14/2023CriticalNoYes
GM03WRG14/12/20234/5/2023CriticalYesYes

 

1 REPLY 1
lbendlin
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lc89CoAwDAXgu3QutC9JrY6C0kVBXRzE+1/Dopbq4g9kePA+QrIsypcgzyJKKzYUxxLf8qqfEDKSQsgxKu9iJYYksRhcZnXdgmw/7AWQEfAF2VfEhi+bQm+p6sbmQJebUj4Rz1PAUdBPlJ5bNw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [serialnumber = _t, Escalated_Date = _t, Prediction_Date = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Escalated_Date", type date}, {"Prediction_Date", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Prediction before Escalation", each if [Prediction_Date]<[Escalated_Date] then 1 else 0,Int64.Type),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"serialnumber"}, {{"SN_PbE", each List.Max([Prediction before Escalation]), type number}, {"Rows", each _, type table [serialnumber=nullable text, Escalated_Date=nullable date, Prediction_Date=nullable date, Prediction before Escalation=number]}}),
    #"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Escalated_Date", "Prediction_Date", "Prediction before Escalation"}, {"Escalated_Date", "Prediction_Date", "Prediction before Escalation"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Rows",{"serialnumber", "Escalated_Date", "Prediction_Date", "Prediction before Escalation", "SN_PbE"})
in
    #"Reordered Columns"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors