Power BI / DAX - COUNT Frequency of Unique strings/values across multiple columns

239 Views Asked by At

I have a table with 3 columns like this:

Table1

enter image description here

In PowerBI I would like to count the frequency of each unique value/string and get it in a seperate table like this:

Table2

enter image description here

I'm finding all different ways of getting a list of the unique values like this:

Table2 = 
     DISTINCT(
          UNION(
              DISTINCT('Table1'[Column1]),
              DISTINCT('Table1'[Column2]),
              DISTINCT('Table1'[Column3])
          )
     )

Which now only gives me a list of distinct values/strings, but not with the count:

enter image description here

And I don't know how to get the count column with it.

Could someone help me to get the counts with it as well?

2

There are 2 best solutions below

3
Xela On BEST ANSWER

Using calculated DAX table can lower your performances, depending on the size of your dataset. The easiest way would have been to do the transformation in Power Query: new query based on source table, delete unrelevant columns, unpivot your 3 columns, then you can summarize and count on a visual matrix/table.

0
Marco Vos On

This should do the trick:

Tabel2 =
VAR T1 =
    SELECTCOLUMNS ( Tabel1, "UniqueValue", 'Tabel1'[Column1] )
VAR T2 =
    SELECTCOLUMNS ( Tabel1, "UniqueValue", 'Tabel1'[Column2] )
VAR T3 =
    SELECTCOLUMNS ( Tabel1, "UniqueValue", 'Tabel1'[Column3] )
VAR T4 =
    UNION ( T1, T2, T3 )
RETURN
    GROUPBY ( T4, [UniqueValue], "Count", SUMX ( CURRENTGROUP (), 1 ) )