Power query conditional column

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Is that possible to add a conditional column with such statement in Excel Power Query?
Excel Formula:
= Table.AddColumn(#"Classified rows", "Personalize", each if QueryA[MyData] = "X" and QueryB[MyData] = "Y"  then "Z" else [MyData)
Also a simplier formula like if [MyData]="1" then QueryA[MyData] return a list of values not the corresponding QueryA MyData row data.
It's not working.Thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
QueryA[MyData] is a List and "X" is a Value so QueryA[MyData] = "X" will be FALSE, the same with the second element
maybe post via XL2BB representative example(s), M you are using and expected result or share excel file with these example via OneDrive, GoogleDrive, DropBox or any similar service
all with detailed info what are you trying to achieve
 
Last edited:
Upvote 0
QueryA[MyData] and QueryB[MyData] refer to the whole column [MyData] as list

You need to add index column

Power Query:
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
custom = Table.AddColumn(#"Added Index", "Personalize", each if QueryA[MyData]{[Index]} = "X" and QueryB[MyData]{[Index]}  = "Y" then "Z" else [MyData])
 
Upvote 0
I managed to achieve the goal using append and merge queries.
Thanks all
 
Upvote 0

Forum statistics

Threads
1,223,744
Messages
6,174,253
Members
452,553
Latest member
red83

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