Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi good day can anyone correct my calculated column. basically what i required is if the column A contain "DISC" and "SILICON" should be equal to 0, and if contain "DISCHARGE DISC" should be equal to 1
Subtable =
SWITCH (
TRUE (),
CONTAINSSTRING ( 'Table01'[ColumnA], "DISC" ) || 'Table01'[ColumnA] = "0", "0",
CONTAINSSTRING ( 'Table01'[ColumnA], "SILICON" ) || 'Table01'[ColumnA] = "0", "0",
CONTAINSSTRING ( 'Table01'[ColumnA], "DISCHARGE HOSE" ) || 'Table01'[ColumnA] = "1", "1"
)
Thnak you
Solved! Go to Solution.
Hi @AllanBerces ,
Thanks for reaching out to the Microsoft Fabric Community.
The behavior occurs because CONTAINSSTRING() performs partial matching, so "DISC" can also match text within another word such as "DISCHARGE". If the requirement is to match "DISC" as a standalone word only, you can try the following calculated column:
Subtable =
VAR _Text = " " & UPPER('Table01'[ColumnA]) & " "
RETURN
SWITCH(
TRUE(),
CONTAINSSTRING(_Text, " DISCHARGE DISC "), 1,
CONTAINSSTRING(_Text, " DISC ")
|| CONTAINSSTRING(_Text, " SILICON "), 0,
BLANK()
)
I tested this with sample data and got the expected results below:
Please find attached .pbix for reference.
Hope this helps. Please reach out for further assistance.
Thank you.
Subtable =
SWITCH(
TRUE(),
CONTAINSSTRING('Table01'[ColumnA], "DISCHARGE HOSE"), "1",
CONTAINSSTRING('Table01'[ColumnA], "DISC"), "0",
CONTAINSSTRING('Table01'[ColumnA], "SILICON"), "0"
)
SWITCH evaluates top to bottom and stops at the first match. Order matters here.
I'm confused. What is the purpose of Table01'[ColumnA] = "0" which is not in your explanation? Also should it contain either DISC and SILICON or DISC or SILICON as the first and second conditions in your DAX point to an OR logic?
Hi @AllanBerces ,
I'm not completely sure what your requirements are but there are definitely a few points in your definition that are probably incorrect:
Hope that helps already. If not, please provide some more details about what is the expected result and what is the current result.
Hi @AllanBerces ,
Thanks for reaching out to the Microsoft Fabric Community.
The behavior occurs because CONTAINSSTRING() performs partial matching, so "DISC" can also match text within another word such as "DISCHARGE". If the requirement is to match "DISC" as a standalone word only, you can try the following calculated column:
Subtable =
VAR _Text = " " & UPPER('Table01'[ColumnA]) & " "
RETURN
SWITCH(
TRUE(),
CONTAINSSTRING(_Text, " DISCHARGE DISC "), 1,
CONTAINSSTRING(_Text, " DISC ")
|| CONTAINSSTRING(_Text, " SILICON "), 0,
BLANK()
)
I tested this with sample data and got the expected results below:
Please find attached .pbix for reference.
Hope this helps. Please reach out for further assistance.
Thank you.
Hi @v-veshwara-msft @Kedar_Pande @danextian @Hans-Georg_Puls thank you very much or highligthing and explanation. Work perfectly
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 30 | |
| 25 | |
| 25 | |
| 23 | |
| 16 |
| User | Count |
|---|---|
| 45 | |
| 32 | |
| 18 | |
| 16 | |
| 16 |