Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi
How do I count the words (not rows) in a specific table or column if there is more than one word in each cell.
Best
/Uno
Solved! Go to Solution.
It would be good if you could mark the post as the solution if it has solved your problem.
Thanks.
Best
Darek
DAX is not the right tool to deal with this. Use Power Query. I'm not even sure it's possible. If it is, it'll be extremely hard.
Best
Darek
Ok, thanks anyway
If you really need it in DAX, then here it is:
[Word Count] = var __selectedWord = SELECTEDVALUE( TableWithIndividualWords[Name] ) var __selectedWordLength = LEN( __selectedWord ) var __wordCount = SUMX( YourTable, -- this table will honor any filters you put on it var __name = YourTable[Name] var __nameLength = LEN( __name ) var __wordCountInRow = ( __nameLenth - LEN(SUBSTITUTE( __name, __selectedWord, ""))) / __selectedWordLength return __wordCountInRow ) return __wordCount
But to get this working you have to have a table that stores all the possible words you could encounter in advance. And the table should stand on its own, without any relationships to any other table. I named the table TableWithIndividualWords and it has only one column [Name] where you store all the possible words. To make this into a visual table you just drag the column from the table so that individual words are visible and drop the measure. It'll calculate the number of times the word appears anywhere in the first table (YourTable).
Best
Darek
Thank you vary much.
@Anonymous wrote:If you really need it in DAX, then here it is:
[Word Count] = var __selectedWord = SELECTEDVALUE( TableWithIndividualWords[Name] ) var __selectedWordLength = LEN( __selectedWord ) var __wordCount = SUMX( YourTable, -- this table will honor any filters you put on it var __name = YourTable[Name] var __nameLength = LEN( __name ) var __wordCountInRow = ( __nameLenth - LEN(SUBSTITUTE( __name, __selectedWord, ""))) / __selectedWordLength return __wordCountInRow ) return __wordCountBut to get this working you have to have a table that stores all the possible words you could encounter in advance. And the table should stand on its own, without any relationships to any other table. I named the table TableWithIndividualWords and it has only one column [Name] where you store all the possible words. To make this into a visual table you just drag the column from the table so that individual words are visible and drop the measure. It'll calculate the number of times the word appears anywhere in the first table (YourTable).
Best
Darek
Wow, thanks. I guess the sentence "stores all the possible words you could encounter in advance" will be the thing that makes it hard to use. Seems quite easy but appearently it is not. The problem occured when hade created a word map and wanted to creat a slicer from the words accouring in it.
So you advice would be to instead create a separate table "by hand" using excel?
/U
Aaah, there it is!!
Thank you very much!
/U
It would be good if you could mark the post as the solution if it has solved your problem.
Thanks.
Best
Darek
Ok, I will give it a try even if it´s a bit above my level. Your help is much appreciated.
Thanks a lot
/U
Hi there.
Mate, the last link I sent you shows you exactly how to obtain a table with all the distinct words that you can find in your table. Please follow it and you'll have the table I was talking about. Then everything is very simple.
Best
Darek
No. My advice is to extract all individual words from the table using Power Query. This is the right tool to do it. Not Excel.
Best
Darek
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |