Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jshiv
New Member

Trying to create a column with multiple arguments

I'm looking to create a new column with several IF and OR arguments but there is only a max of 2 allowed.

I have seen that || can be used, but I'm unsure of where to use it. I'm relatively new to PowerBi.

 

Measure = IF(OR('LT'[NBR]=6002,'LT'[NBR]=7102,'LT'[NBR]=7088,'LT'[NBR]=7087),"ON1",IF(OR('LT'[NBR]=6063,'LT'[NBR]=7101,'LT'[NBR]=6081,'LT'[NBR]=6080),"AB",IF(OR('LT'[NBR]=7103,'LT'[NBR]=6097,'LT'[NBR]=6098,'LT'[NBR]=6093),"ON2",IF(OR('LT'[NBR]=6072,'LT'[NBR]=6064),"BC",IF('LT'[NBR]=6083,"SK","unknown")))))
1 ACCEPTED SOLUTION

hi @jshiv 

aha, try like:

column = 
SWTICH(
    TRUE(),
    [NBR] IN {6002, 7102, 7087}, "ON1",
    [NBR] IN {6063, 7101, 6081, 6080}, "AB",
    [NBR] IN {7103, 6097, 6098, 6093}, "ON2",
    [NBR] IN {6072, 6064}, "BC", 
    [NBR]=6083, "SK", 
    "unknown"
)

View solution in original post

7 REPLIES 7
jshiv
New Member

I tried it, but keep getting the following error; 

 

A single value for column 'NBR' in table 'LT' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

hi @jshiv 

are you creating the column in LT table?

Yes I am

FreemanZ
Super User
Super User

hi @jshiv 

try like:

column = 
SWTICH(
    [NBR],
    6002 || 7102 || 7087, "ON1",
    6063 || 7101 || 6081 || 6080, "AB",
    7103 || 6097 || 6098 || 6093, "ON2",
    6072 || 6064,  "BC", 
    6083,  "SK", 
    "unknown"
)

I tried inputting a New Column instead of a New Measure and get the following error:

 

Function 'SWITCH' does not support comparing values of type Integer with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.

hi @jshiv 

aha, try like:

column = 
SWTICH(
    TRUE(),
    [NBR] IN {6002, 7102, 7087}, "ON1",
    [NBR] IN {6063, 7101, 6081, 6080}, "AB",
    [NBR] IN {7103, 6097, 6098, 6093}, "ON2",
    [NBR] IN {6072, 6064}, "BC", 
    [NBR]=6083, "SK", 
    "unknown"
)

Perfect, thank you!!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.