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
Ammar-Jaradat
Frequent Visitor

Add conditional column with different arguments

Hello, I seem help in creating a conditional column based on two different values from different columns

 

Here is an example

 

If Level Value = 1 and Hours <= 9, Then Return 1, Else Return 0

If Level Value = 2 and Hours <= 12, Then Return 1, Else Return 0

If Level Value =3 and Hours<= 24, Then Return 1, Else Return 0

If Level Value =0 , Then Return 1

 

AmmarJaradat_0-1671018381379.png

 

Thank you for your support

4 REPLIES 4
Ammar-Jaradat
Frequent Visitor

This one does not seem working, apologise, i will submit a clear description with real data 

Ammar-Jaradat
Frequent Visitor

Thank you for your answer. But it doe snot seem to be working.. May i kindly request some clarifications on the steps i need to follow?

Ammar-Jaradat
Frequent Visitor

Hello @JW_van_Holst , Thank you for your answer. But it doe snot seem to be working.. May i kindly request some clarifications on the steps i need to follow?

JW_van_Holst
Resolver IV
Resolver IV

Here you are.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WslTSUTIE41idaCVDIyDTCM41MgEyjRGyBlDFBhCuMVQxhGtkClUM5VqAmWBuLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Hours = _t, #"Level Value" = _t, #"New Column Value" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hours", Int64.Type}, {"Level Value", Int64.Type}, {"New Column Value", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Conditional Column", each 
    if 
        ([Level Value]=1 and [Hours]<=9) or 
        ([Level Value]=2 and [Hours]<=12) or
        ([Level Value]=3 and [Hours]<=24) 
    then 
        1
   else 
        0
    , type number)
in
    #"Added Custom"

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 Fabric 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.