Forum Discussion
Calculate with filters and Contaimstring with OR
- 6 years ago
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.