Excel Power Query Nested If

RICH937

Board Regular
Joined
Apr 15, 2023
Messages
59
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi Excel People!
I tried my first nested "if/then" in PQ today, but am only getting "D" as a response. Can someone help me understand why? I pulled a similar formula from excel off the grid: Power Query If statement: nested ifs & multiple conditions Here's mine:
= Table.AddColumn(#"Reordered Columns1", "Custom", each if [COLUMN NAME A ]="TRUE" then
if [#"COLUMN NAME B FROM MERGE"]="TRUE" then "A" else "C"
else
if [#"COLUMN NAME FROM MERGE)"]="TRUE" then "B"
else "D")
==>all results in my PQ editor are "D"

In excel this would be: if([@column name]=true, if([@column name b]=true, "A","C"), if([@column name b]=true, "b", "d")

Any help in what I did wrong would be greatly appreciated!

Thank you!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You are using text instead of boolean for comparison. If the mentioned column values are boolean, then you should user true and false instead of "TRUE" and "FALSE".
Could you please try the following instead?

Power Query:
Table.AddColumn(#"Reordered Columns1", "Custom", 
        each 
            if [COLUMN NAME A ]=true then
                if [#"COLUMN NAME B FROM MERGE"]=true then "A" else "C"
            else
                if [#"COLUMN NAME FROM MERGE)"]=true then "B"
            else "D"
        )
 
Upvote 0
Solution
arrrrrgh! thank you. The True/False values were drawn from a conditional formula column with the results in all caps. PQ didn't recognize TRUE or FALSE unless I added the "TRUE" and "FALSE". I swapped to the lowercase, and it's working perfectly. That's what I get for being hyper vigilant on text case in PQ!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top