Reputation: 15
I have a table in Power BI named 'Data' which contains a field named 'Carrier'.
I need to create a new measure that would be similar to the following I have in SQL:
case when carrier NOT IN ('UA' , 'LH' , 'LX' , 'OS' , 'SN' , 'AA' , 'IB' , 'BA' , 'AY' , 'AS' , 'B6' , 'DL' , 'AF' , 'KL' , 'VS' , 'WN') then 'Other' else carrier
However I don't know the proper syntax. Please assist. Thank you!
Upvotes: 1
Views: 993
Reputation: 441
You need a switch statement.
NewMeasure = SWITCH('TableName'[Carrier}],
"UA", "UA",
"LH", "LH",
"LX", "LX",
"OS", "OS",
"SN", "SN",
"AA", "AA",
"IB", "IB",
"BA", "BA",
"AY", "AY",
"AS", "AS",
"B6", "B6",
"DL", "DL",
"AF", "AF",
"KL", "KL",
"VS", "VS",
"WN", "WN",
"Other"
)
It checks the Carrier field and returns the same value if i's in one of the specified carrier codes. If the value isn't in the list, then it returns 'Other'.
I highly recommend checking out Dax Patterns below and reading the documentation if you're going to be using PowerBI. It will save you a ton of time. Microsoft Documentation Dax Patterns
Upvotes: 1