Forum Discussion
How to count unique strings across multiple columns
Hi
I am hoping someone can help me with a table i am struggling with.
I have multiple columns with varying numbers of rows in each. Across the rows/columns are various single word strings, and i am just looking to output a single column that identifies each string found and how many times it occurs. A particular string may appear multiple times in different columns (i.e. the string 'mystring' may occur 10 times in column A and also 15 times in column C)
Example input:
| Shoe | hat | glove | Sock | Sock |
| hat | jacket | jacket | glove | glove |
| hat | jacket | shoe | hat | |
| jacket | jacket | Sweater |
output i am looking for:
| Shoe | 2 |
| Hat | 4 |
| Jacket | 5 |
| Glove | 3 |
| Sweater | 1 |
| Sock | 2 |
Note that my actual dataset is huge, and i wont know all the words that are in there to manually query each word.
Any help is gratefully received
projman OK, I mocked this up. PBIX is attached under signature. I think I left out a DISTINCT in the table calc so that is there now.
Table2 = VAR tmpCol1 = SELECTCOLUMNS(Data,"Column",[Column1]) VAR tmpCol2 = SELECTCOLUMNS(Data,"Column",[Column2]) VAR tmpCol3 = SELECTCOLUMNS(Data,"Column",[Column3]) VAR tmpCol4 = SELECTCOLUMNS(Data,"Column",[Column4]) VAR tmpCol5 = SELECTCOLUMNS(Data,"Column",[Column5]) VAR tmpTable = DISTINCT(UNION(tmpCol1,tmpCol2,tmpCol3,tmpCol4,tmpCol5)) RETURN tmpTableYou want Data and Table2 tables in the PBIX.