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
Irwin
Helper IV
Helper IV

Selective combine 3 columns in Power Query ?

Hi guys,

 

I have 3 columns that I would like to combine into one. I would like to do this in power query as I have alot of rows.

The columns contain values from null, 0, 1,2.... to ~25 (see example)

 

I would like power query to check column 1 and if there is a number, use this in the new column. If null or 0, then check column 2 and use this number. If this is also null or 0, then use result from column 3. 

 

Irwin_0-1635249293333.png

 

How can I do this in the power query?

Thank you for all answers 🙂

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You can add a custom column with an expression like this to get your result.

 

= List.First(List.Select({[Column1], [Column2], [Column3]}, each _ <> null and _ <> 0))

 

mahoneypat_0-1635250210654.png

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

You can add a custom column with an expression like this to get your result.

 

= List.First(List.Select({[Column1], [Column2], [Column3]}, each _ <> null and _ <> 0))

 

mahoneypat_0-1635250210654.png

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


This works. Thanks!

 

Now that I have begun to grasp how DAX works I have realised that much of my work would be better done in the power query, so I need to learn M aswell... 

I dont understand why your code does, but it will suffice for now, and then down the road I will understand why. 🙂

 

Thank you again.

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.