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
Anonymous
Not applicable

Multiple IF condition formula in Power Query

I am new to Power Query and trying to replicate the below excel formula in power query-

 

IF(A6="P",IF((D6*E6*F6)>=3284,ROUND((D6*E6*F6)/110,0),ROUND((D6*E6*F6)/200,0)),IF(A6="LTL",ROUND((D6*E6*F6)/175,0),0))

 

Any help is much appreciated!

1 ACCEPTED SOLUTION
JW_van_Holst
Resolver IV
Resolver IV

Of course PQ doesn't know cell reference, so I build a table with column names that refence your excel columns. In the last column ("Result') you see the conditional column.

 

Picture1.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WClDSUTICYlMgNjQAEUqxOtFKPiE+2CUCwCwINjayMAFRBmhajMByIClzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, D = _t, E = _t, F = _t, expected = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"D", Int64.Type}, {"E", Int64.Type}, {"F", Int64.Type}, {"expected", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "D*E*F", each [D]*[E]*[F], type number),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "result", each if [A] = "P" then 
   if [#"D*E*F"] >= 3284 then 
       Number.Round([#"D*E*F"]/110,0) 
       else 
       Number.Round([#"D*E*F"]/200,0)
else 
    if [A]="LTL" then 
        Number.Round([#"D*E*F"]/175,0) 
    else 
    0, type number)
in
    #"Added Custom1"

 

 

View solution in original post

1 REPLY 1
JW_van_Holst
Resolver IV
Resolver IV

Of course PQ doesn't know cell reference, so I build a table with column names that refence your excel columns. In the last column ("Result') you see the conditional column.

 

Picture1.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WClDSUTICYlMgNjQAEUqxOtFKPiE+2CUCwCwINjayMAFRBmhajMByIClzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, D = _t, E = _t, F = _t, expected = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"D", Int64.Type}, {"E", Int64.Type}, {"F", Int64.Type}, {"expected", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "D*E*F", each [D]*[E]*[F], type number),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "result", each if [A] = "P" then 
   if [#"D*E*F"] >= 3284 then 
       Number.Round([#"D*E*F"]/110,0) 
       else 
       Number.Round([#"D*E*F"]/200,0)
else 
    if [A]="LTL" then 
        Number.Round([#"D*E*F"]/175,0) 
    else 
    0, type number)
in
    #"Added Custom1"

 

 

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.