Excel Power Query Nested If

RICH937

Board Regular
Joined
Apr 15, 2023
Messages
53
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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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,215,200
Messages
6,123,598
Members
449,109
Latest member
Sebas8956

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