Jun 16 2022 07:25 AM
Vendor 1 | Vendor 2 | Vendor 3 | Vendor Master |
ABC | |||
BCD | |||
CDE |
Hi everyone, I'm trying to put up a IF formula for the following scenario. But I'm facing difficulty in getting the proper solution. It would be great if someone would help me to build a proper formula for this one.
Problem statement:
I have 3 columns for Vendors i.e Vendor 1, Vendor 2, Vendor 3. I want to put up a formula in "Vendor Master" such that IF "Vendor 1" is blank then it should return value from "Vendor 2" in "Master Vendor".
IF "Vendor 2" is also blank then it should return value from "Vendor 3".
IF "Vendor 3" is blank then it should return a string "No Vendor".
It would also be great if someone could tell me how this can be done in Power BI as well.
Quick response is highly appreciated.
Thanks in advance.
Jun 16 2022 07:33 AM
I'm pretty sure someone will have a more eloquent formula but this can be done with nested IF formula - see attached example
=IF($A2>"",$A2,IF($B2>"",$B2,IF($C2>"",$C2,0)))
Jun 16 2022 11:03 AM
If under Power BI you mean transformation in Power Query, you may add custom column as
= Table.AddColumn( Source,
"Vendor Master",
each List.RemoveNulls(Record.FieldValues( _ )){0} )
Jun 16 2022 09:21 PM
Jun 17 2022 12:40 AM
For PowerBI/Power Query, similar to @Sergei Baklan with the "No vendor" exception:
= Table.AddColumn(PreviousStep, "Vendor Master", each
try List.RemoveNulls(Record.ToList(_)){0} otherwise "No vendor"
)
Jun 21 2022 10:07 PM
I have 15 other columns in my dataset. Will this code still work?
Jun 21 2022 10:29 PM
Record.FieldValues and Record.ToList take a Record ("row" if you prefer) and return a List containing all values from that Record, whatever the number of columns is
Jun 21 2022 10:41 PM - edited Jun 21 2022 10:42 PM
@SatishBadiger
If you have Filter and each row has only one entry, you could use
=FILTER(A2:C2,A2:C2<>"")