The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi.. Here's an example.
I have a column with strings in it the cell contains text in form of abc_bcd_cba_xyz and I want to count number of times abc, xyz, def occur. so the output should be 2.
Solved! Go to Solution.
Hi, @santpras0
May I ask if you have solved this problem? Depending on your needs you can either try @JamesFR06 's method or try the following.
Measure:
WordCount =
VAR _searchText1 = "abc"
VAR _searchText2 = "xyz"
VAR _targetText =
SELECTEDVALUE ( 'Table'[String] )
VAR _abc =
SUMX ( 'Table', IF ( CONTAINSSTRING ( _targetText, _searchText1 ), 1 ) )
VAR _xyz =
SUMX ( 'Table', IF ( CONTAINSSTRING ( _targetText, _searchText2 ), 1 ) )
RETURN
_abc + _xyz
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi, @santpras0
May I ask if you have solved this problem? Depending on your needs you can either try @JamesFR06 's method or try the following.
Measure:
WordCount =
VAR _searchText1 = "abc"
VAR _searchText2 = "xyz"
VAR _targetText =
SELECTEDVALUE ( 'Table'[String] )
VAR _abc =
SUMX ( 'Table', IF ( CONTAINSSTRING ( _targetText, _searchText1 ), 1 ) )
VAR _xyz =
SUMX ( 'Table', IF ( CONTAINSSTRING ( _targetText, _searchText2 ), 1 ) )
RETURN
_abc + _xyz
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi
Try this :
testcoptage =
CALCULATE ( COUNTROWS ( Occur ), CONTAINSSTRINGEXACT ( Occur[Column1], "abc" ) )
+ CALCULATE ( COUNTROWS ( Occur ), CONTAINSSTRINGEXACT ( Occur[Column1], "xyz" ) )
User | Count |
---|---|
24 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |