Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hey,
Trying to create a custom column where it's value is dependent on [ID] and sometimes [Item] to determine a colour.
Any clue why the below is not working? I get an error message that the last 'then' is expecting a bracket?
= Table.AddColumn(#"Removed Spaces", "Custom", each if [ID] = "A" then "Red" else (if [ID] = "B" then "Red" else (if [ID] = "C" then "Red" else (if [ID] = "D" then "Red" else (if [ID] = "E" then "Blue" else (if [ID] = "F" then "Red" else (if [ID] = "G" then "Red" else (if([ID] = ("H") or [ID] = ("I") or [ID] = ("J") or [ID] = ("K") or [ID] = ("L")) then (if [Item] = "Socks" then "Green" else if([Item] = "Shirt" then "Yellow" else [ID]))))
Thank you in advance!
Solved! Go to Solution.
= Table.AddColumn(#"Removed Spaces", "Custom", each
if [ID] = "A" then "Red"
else if [ID] = "B" then "Red"
else if [ID] = "C" then "Red"
else if [ID] = "D" then "Red"
else if [ID] = "E" then "Blue"
else if [ID] = "F" then "Red"
else if [ID] = "G" then "Red"
else if [ID] = "H" or [ID] = "I" or [ID] = "J" or [ID] = "K" or [ID] = "L" then
if [Item] = "Socks" then "Green"
else if [Item] = "Shirt" then "Yellow"
else [ID]
else null
)
Based on my understanding, I recreated this query. Pls use it and let me know if it works or not.
Thanks so much, it worked!
= Table.AddColumn(#"Removed Spaces", "Custom", each
if [ID] = "A" then "Red"
else if [ID] = "B" then "Red"
else if [ID] = "C" then "Red"
else if [ID] = "D" then "Red"
else if [ID] = "E" then "Blue"
else if [ID] = "F" then "Red"
else if [ID] = "G" then "Red"
else if [ID] = "H" or [ID] = "I" or [ID] = "J" or [ID] = "K" or [ID] = "L" then
if [Item] = "Socks" then "Green"
else if [Item] = "Shirt" then "Yellow"
else [ID]
else null
)
Based on my understanding, I recreated this query. Pls use it and let me know if it works or not.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.