Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello everyone, i need help for elaborate a med.
I need to calculate the amount the records in the collunm by type text that contaim the diferents words.
For Example, I need a formula that brings me the added value if the column contains the text XXXX or YYYY or ZZZZZ
I thing that has beem something with CALCULATE / FILTER / CONTAINSTRING (or other text function) with the funcition OR
How i can do that ?
Thanks a lot for the answers.
Solved! Go to Solution.
Hi, @Portrek
Based on your description, I assume that you want to count rows which contains specific words and get the text which excludes the specific words. I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create two measures as below.
CountRecords =
COUNTROWS(
FILTER(
ALL('Table'),
CONTAINSSTRINGEXACT('Table'[Text],"XXXX")||
CONTAINSSTRINGEXACT('Table'[Text],"YYYY")||
CONTAINSSTRINGEXACT('Table'[Text],"ZZZZ")
)
)
Result =
var _text = SELECTEDVALUE('Table'[Text])
return
SWITCH(
TRUE(),
CONTAINSSTRINGEXACT(_text,"XXXX"),
SUBSTITUTE(_text,"XXXX",""),
CONTAINSSTRINGEXACT(_text,"YYYY"),
SUBSTITUTE(_text,"YYYY",""),
CONTAINSSTRINGEXACT(_text,"ZZZZ"),
SUBSTITUTE(_text,"ZZZZ","")
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Portrek
Based on your description, I assume that you want to count rows which contains specific words and get the text which excludes the specific words. I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create two measures as below.
CountRecords =
COUNTROWS(
FILTER(
ALL('Table'),
CONTAINSSTRINGEXACT('Table'[Text],"XXXX")||
CONTAINSSTRINGEXACT('Table'[Text],"YYYY")||
CONTAINSSTRINGEXACT('Table'[Text],"ZZZZ")
)
)
Result =
var _text = SELECTEDVALUE('Table'[Text])
return
SWITCH(
TRUE(),
CONTAINSSTRINGEXACT(_text,"XXXX"),
SUBSTITUTE(_text,"XXXX",""),
CONTAINSSTRINGEXACT(_text,"YYYY"),
SUBSTITUTE(_text,"YYYY",""),
CONTAINSSTRINGEXACT(_text,"ZZZZ"),
SUBSTITUTE(_text,"ZZZZ","")
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Can you try the below function?
Count_string = CALCULATE ( COUNTROWS ( 'Table' ), CONTAINSSTRING ( Table[Column], "XXXX" ) || CONTAINSSTRING ( Table[Column], "YYYY" ) ) |
Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂
Regards,
N V Durga Prasad
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
74 | |
57 | |
38 | |
33 |
User | Count |
---|---|
70 | |
63 | |
55 | |
48 | |
46 |