cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Impactful Individual
Impactful Individual

Power Query: Check for a value(date) in three columns

Hi,

 

How do I use M to check for a value from multiple columns, in my case 3.

 

In my situation I am looking for a value in a specific order, say column 1 first, then column 2 and then 3. Whoever is non-empty, grab the value.

 

Something like

 

comment: with  Column X as placeholder

 

if ColumnA <> "" then

    ColumnX = ColumnA

else

      if ColumnB <> "" then

           ColumnX = ColumnB

       else

              if ColumnC <> "" then

                    ColumnX = ColumnC

              end if

        end if

end if

1 ACCEPTED SOLUTION
Community Support
Community Support

Hi @ovetteabejuela,


You can add a custom column to use below formula to check different columns.

AddColumn = Table.AddColumn(#"Promoted Headers", "ColumnX", each if [ColumnA]<> null then [ColumnA] else if [ColumnB]<> null then [ColumnB] else if [ColumnC] <> null then [ColumnC] else null)

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @ovetteabejuela,


You can add a custom column to use below formula to check different columns.

AddColumn = Table.AddColumn(#"Promoted Headers", "ColumnX", each if [ColumnA]<> null then [ColumnA] else if [ColumnB]<> null then [ColumnB] else if [ColumnC] <> null then [ColumnC] else null)

 

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

@v-shex-msft,

 

Thanks, you beat me to it.. I did see some resource over the internet as well and this is definitely it, I'll just have to apply it and see how it goes but I think this is it.

 

Thanks again.

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors