Forum Discussion
CASE WHEN
- 4 years ago
Hi, Anonymous ;
You could add conditional column in power query as follows:
The final output is shown below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMzNVitWJVjI2MDABMywtzczADENDAyMoy8AATFtAVRhCVQAZEM2GxoYWRkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Org ID" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Org ID", Int64.Type}}), #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Org ID] = 10665 then "A" else if [Org ID] = 3004 then "B" else if [Org ID] = 9966 then "C" else if [Org ID] = 11026 then "D" else if [Org ID] = 100 then "E" else if [Org ID] = 84 then "F" else if [Org ID] = 9166 then "G" else if [Org ID] = 9165 then "H" else if [Org ID] = 13182 then "G" else null) in #"Added Conditional Column"Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous , Use Switch
Switch ([Org ID],
10665 ,"A",
3004 ,"B",
//Add other
""
)
Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56
amitchandak is it doable in power query using Custom Column?
- amitchandak4 years agoSuper User
Anonymous , Power Query if then else
if [Org ID] =10665 then "A" else
if [Org ID] =10665 then "B" else///// Add other
3004
nested if then else, Take care of datatype, text should be double quote
- Anonymous4 years agoNot applicable
amitchandak output is showing errors
- amitchandak4 years agoSuper User
Anonymous , Try like
if [Org ID] = 10665 then "A" else
if [Org ID] = 3004 then "B" else
if [Org ID] = 9966 then "C" else
if [Org ID] = 11026 then "D" else
if [Org ID] = 100 then "E" else
if [Org ID] = 84 then "F" else
if [Org ID] = 9166 then "G" else
if [Org ID] = 9165 then "H" else
if [Org ID] = 13182 then "I" else ""or share the data and error