Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Is there a shorter code for this:
SWITCH(TRUE(), ISERROR(SEARCH("RED", 'Sheet1'[Color])) <> TRUE (), "Primary",
SWITCH(TRUE(), ISERROR(SEARCH("YELLOW", 'Sheet1'[Color])) <> TRUE (), "Primary",
SWITCH(TRUE(), ISERROR(SEARCH("BLUE", 'Sheet1'[Color])) <> TRUE (), "Primary",
SWITCH(TRUE(), ISERROR(SEARCH("ORANGE", 'Sheet1'[Color])) <> TRUE (), "Secondary",
...and so on.... I was wondering if there is a shorter way of doing it
Color | Color Groups -> This is is the result of the dax code above |
Red | Primary
|
Yellow
| Primary |
Blue
| Primary |
Orange
| Secondary |
Green
| Secondary |
Yellow Orange | Tertiary |
Yellow Green | Tertiary |
Solved! Go to Solution.
@Honne2021 how about this?
In general you only need to use the SWITCH one time
I also changed fro iserror so contatinstring:
Column =
SWITCH(
TRUE(),
CONTAINSSTRING('Sheet1'[Color], "Yellow Orange") || CONTAINSSTRING('Sheet1'[Color], "Yellow Green"), "Tetriary",
CONTAINSSTRING('Sheet1'[Color], "Red") || CONTAINSSTRING('Sheet1'[Color], "Yellow") || CONTAINSSTRING('Sheet1'[Color], "Blue"), "Primary",
CONTAINSSTRING('Sheet1'[Color], "Green") || CONTAINSSTRING('Sheet1'[Color], "Orange"), "Secondary"
)
Here is a link to download a sample solution file:
If text contains then, multiple results based on condition 2022-08-02.pbix
@Honne2021 how about this?
In general you only need to use the SWITCH one time
I also changed fro iserror so contatinstring:
Column =
SWITCH(
TRUE(),
CONTAINSSTRING('Sheet1'[Color], "Yellow Orange") || CONTAINSSTRING('Sheet1'[Color], "Yellow Green"), "Tetriary",
CONTAINSSTRING('Sheet1'[Color], "Red") || CONTAINSSTRING('Sheet1'[Color], "Yellow") || CONTAINSSTRING('Sheet1'[Color], "Blue"), "Primary",
CONTAINSSTRING('Sheet1'[Color], "Green") || CONTAINSSTRING('Sheet1'[Color], "Orange"), "Secondary"
)
Here is a link to download a sample solution file:
If text contains then, multiple results based on condition 2022-08-02.pbix
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
79 | |
63 | |
52 | |
47 |
User | Count |
---|---|
217 | |
89 | |
76 | |
66 | |
60 |