Search code examples
powerbipowerquerypowerbi-desktop

Counting column values uniquely in Power BI


I have a column "Text" which holds values like :

Text
A
B
A B
A B C
A B C D

I want to visualize this column in Power BI in a bar chart but I want the values uniquely on the y axis and there count as the following:

So value "A" will have a count of 4 as "A" appears four times in all the rows similarly B will have a count of 4 and so on for C and D

I also want to ensure that on the y axis I just see the unique values like A, B , C and D.

So the final output should look like this: [![enter image description here][1]][1]

any ideas how can I achieve this? [1]: https://i.sstatic.net/bw31g.png


Solution

  • Get your data in Power Query like this:

    enter image description here

    Choose Split Column by Delimiter from the Transform ribbon and fill in as follows:

    enter image description here

    You'll get this.

    enter image description here

    Highlight the column and click Format - Trim.

    enter image description here

    Close & load.

    In Power BI, place a stacked bar chart on the canvas. Drag your column to the field wells as follows:

    enter image description here

    Enable data labels.

    enter image description here