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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
wem
Frequent Visitor

RETURN of SWITCH statements (via variables) via New Column

Hello,

I'm trying to find the right way to RETURN the values defined in the switch statements (Variables). Initially I tried to do this via a new SWITCH statement but that didn't work. I also experimented with IF but wasn't succesfull either.
Each of the VAR-statements returns the expected value when used seperately in a column. But I can't have the results of the different SWITCH statements returned in one column.
Any advice on this?
Thanks in advance
Wim 

Fruit =
VAR PEER =
SWITCH (
TRUE (),
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "golden" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "jonagold" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "granny smith" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "peche" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "nectarine" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "meloen" ), "PEER",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "ananas" ), "PEER",
"-"
)

VAR APPEL =
SWITCH (
TRUE (),
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "opel" ), "APPEL",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "bmw" ), "APPEL",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "mini" ), "APPEL",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "rolls" ), "APPEL",
"-"
)

VAR KIWI =
SWITCH (
TRUE (),
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "stoel" ), "KIWI",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "tafel" ), "KIWI",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "raam" ), "KIWI",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "deur" ), "KIWI",
CONTAINSSTRING ( WORKGROUPSTATS[DNIS], "vuur" ), "KIWI",
"-"
)
RETURN



1 ACCEPTED SOLUTION
KeyurPatel14
Responsive Resident
Responsive Resident

Hi @wem ,
You can return only one variable using RETURN in dax.
If you want to return all the variables then you can concate those 3 variables and then you can return it.
If you have any queries then please let me know and if this is not working for you then please share your expected result so that I can help you.
Thank you.

View solution in original post

2 REPLIES 2
KeyurPatel14
Responsive Resident
Responsive Resident

Hi @wem ,
You can return only one variable using RETURN in dax.
If you want to return all the variables then you can concate those 3 variables and then you can return it.
If you have any queries then please let me know and if this is not working for you then please share your expected result so that I can help you.
Thank you.

Hi @KeyurPatel14 ,

The concatenation was exactly what I was looking for. I didn't expect to become the desired result this way.

Thank you very much for your suggestion/solution.

regards

Wim 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.