Forum Discussion
String block search
- 5 years ago
Hey Wresen ,
first I created a table that contains the "predefined blocks", I called this table "searchstrings" and the column "searchstring", the table looks like this:
The table is NOT related to the item-table.
Then I created this measure:
Measure = var __SearchstringsToFind = VALUES( 'Searchstrings'[searchstring] ) var lengthOfBlock = 3 return COUNTX( Sheet1 , var afunnystring = 'Sheet1'[String] var lengthofstring = LEN( afunnystring ) var noofoccurrences = IF( MOD( lengthofstring , lengthOfBlock ) = 0 , INT( DIVIDE( lengthofstring , lengthOfBlock ) ) , INT( DIVIDE( lengthofstring , lengthOfBlock ) ) + 1 ) var __blocks = ADDCOLUMNS( GENERATESERIES( 1 , noofoccurrences ) , "block" , MID( afunnystring , ''[Value] * lengthOfBlock - 2 , lengthOfBlock ) ) return COUNTROWS( FILTER( __blocks , [block] in __SearchstringsToFind ) ) )It seems the measure is returning the expected result:
Hopefully, this provides what you are looking for.
Regards,
Tom
Hi Wresen ,
My final result is this
The overall process is to copy a table first, then separate it, find the row where abc is located, filter and retain abc, use GROUPBY to count, and finally merge the two tables.
You can check the details from the attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HI Anonymous and thx so much for your help.
I am not sure this will work since its need to be in a measure since in the end the user will be able to filter on some predefined 3 blocks to get a resualt.
Also it need to be in 3 blocks it does its search (string possition 1-3,4-6,7-9 and so on, the sting is very long and can contain duplicats if its not done in a 3block search, otherwise its is unique)
/Thanks