Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Daniel_F
New Member

Count unique values, but some cells have two or more values separated by comma

Guys,

 

i have annoying task to do every month and thought maybe there is some sollution. On a screen below you will see different values that should be counted. I need to count how many times the same value is repeated. It seems nothing complicated, but in some cases there are several values ​​in one field separated by commas, f.e. in a 3rd row we have 3 values 8.15, 6.56 and 3.18, which must be counted as separate values. Value 3.18 repeats 3 times in total, so final result should be 3.18 - 3 

 

 str.PNG

 

Below is final, expected result:

 

fstr.PNG

 

Any suggestion how to count each comma separated value as a separate value? 😉

 

PS.: the word str. will be removed via column transformation

1 ACCEPTED SOLUTION
ddpl
Solution Sage
Solution Sage

@Daniel_F 
Step1: First Seperate the value by comma seperated as per below

ddpl_0-1670479036841.png

result was:

ddpl_1-1670479074035.png

 

Step2:Select all 3 column and unpivot selected column as per below

 

ddpl_2-1670479340235.png

then remove unnecessary column and you can replace str. with blank 

 

now create visual table as per below

ddpl_3-1670479794470.png

 

 

 

 

View solution in original post

6 REPLIES 6
Daniel_F
New Member

Thx for all 🙂 this is what i was looking for 🙂

Mahesh0016
Super User
Super User

Mahesh0016_0-1670486045380.png

Count Text = CALCULATE(COUNTX('Table',COUNT('Table'[_Str])),ALLSELECTED('Table'[Str]))
 
@Daniel_F IT IS HELPFUL FOR YOU
 
TomMartens
Super User
Super User

Hey @Daniel_F ,

 

in a situation like this, I create a new table that contains two columns STR and Row Labels. STR Still contains the comma separated values, whereas Row Labels has the string separated into multiple rows, then you can create a relationship with the original table and write a measure that counts the number of occurrences of a given string now, a Row Label.

The table will look like this:
image.png
In PowerQuery you start with a table containing a single column of unique values of STR, create a duplicate column of STR.
Then you can use the "Split column - By delimiter transformation on the duplicated column:
image.png
Without any measure you can achieve something like this:

image.png

Hopefully, this provides what you are looking for.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
ddpl
Solution Sage
Solution Sage

@Daniel_F 
Step1: First Seperate the value by comma seperated as per below

ddpl_0-1670479036841.png

result was:

ddpl_1-1670479074035.png

 

Step2:Select all 3 column and unpivot selected column as per below

 

ddpl_2-1670479340235.png

then remove unnecessary column and you can replace str. with blank 

 

now create visual table as per below

ddpl_3-1670479794470.png

 

 

 

 

Yes, this is what I need, but now another question has appeared. After i split my column and before unpivot i have to select all newly appeared columns and then select Unpivot selected columns, but what if i'll have more than 3 values ​​separated by comma, f.e. 4-5-6? Then applied steps skip those new 4-5-6 columns. So my question is - is there any function that dynamically unpivot all new appeared columns after split? Hope you understand what I mean 🙂

 

In Applied steps i see this function:

Table.UnpivotOtherColumns(#"Split Column by Delimiter", {}, "Attribute", "Value")

@Daniel_F you can add index column and then unpivot the other column.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.