Using an IN Condition for multiple values in Power Query (Power BI)
In the example I did not want to specify all the country names one row at a time. This not only takes a long time, but if I had to then make updates it could be painful too.
The requirement was for certain countries to have their names and the rest be grouped into “Other Countries”
I found this useful solution in the Power BI Community which was the basis for this blog post Solved: IN OPERATOR in Power BI – Microsoft Power BI Community
To do this I created the following custom column in Power Query
if List.Contains ({“China”
,”Korea”
,”Japan”
,”Thailand”
,”Indonesia”
,”Vietnam”},[Country]) then [Country] else “Other Countries”
And this is what it looked like below.
If you would like to know more details about the List.Contains you can find information here: pq.how – List.Contains
Thanks for reading and I hope that you found this useful!
[…] Gilbert Quevauvilliers is making a list: […]
Nice post. Sometimes I forget how powerful the functional m language is. Can do things simpler in code rather than rely on the GUI for everything.
Hi Donald,
Thanks for the great comment, I appreciate it!