Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
arb1782
Helper III
Helper III

Need help with custom column formula in PowerQuery

Hi

 

I have a table that's built by referencing another table. Within the second table I need to create a custom column ith the following logic

 

If column X = 'xyz', then "yes"

If column Y = 'xyz', then "yes"

Otherwise "no"

 

I wrote the formula in DAX but the custom column function in PowerQuery appears to use a different language. Could anyone please help?

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @arb1782 ,

You could use the following syntax in "Add a custom column" window.

each if [X]="xyz" then "Yes" else if [Y]="xyz" then "Yes" else "No"

9.22.3.1.png

9.22.3.2.PNG

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

View solution in original post

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @arb1782 ,

You could use the following syntax in "Add a custom column" window.

each if [X]="xyz" then "Yes" else if [Y]="xyz" then "Yes" else "No"

9.22.3.1.png

9.22.3.2.PNG

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please upload some insensitive data samples and expected output.

 

Best Regards,
Eyelyn Qin

Thanks all

PaulDBrown
Community Champion
Community Champion

@arb1782 

 

Use the Option in the ribbon to add a new conditional column and write the logic in the interface. You can select different columns.

For example:

PQ Condit Col.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Ah, I didn't spot that before, thanks! I've set it up as is following:

 

If column x CONTAINS 'xyz' then yes

OR if column y is equal to 'xyz' then yes

Otherwise No

 

Mhy remaining problem is that when column x is null, PBI returns error instead of No. Any ideas how to rectify this? There doesn't appear to be 'isnull' in the available criteria.

Any further thoughts on my reply @PaulDBrown 

amitchandak
Super User
Super User

@arb1782 , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Can you see if this can help:https://eriksvensen.wordpress.com/2019/02/28/powerquery-replicate-doing-an-excel-vlookup-in-m/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.