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
Power_BI_Adapt
Resolver I
Resolver I

How to do a unique count per single item?

Dear all,

 

I am seeking for a solution to get a unique count for the following situation:

 

I have a customer table with main customer number and a an additional customer delivery number:

 

Main customer numberDelivery customer number
111123
111134
111145
222234
222245
333345

 

The final result should be a measure showing for the following main customer number the following output:

 

111 ---> unique count of 3 delivery customer numbers

222 ---> unique count of 2 delivery customer numbers

333---> unique count of 1 delivery customer number

 

Any suggestion is welcome how to fix it.

 

Thanks!

1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

Hi @Power_BI_Adapt ,

I think you can use simply the measure COUNTROWS('Table') and put it in matrix with the Main Customer Number column in the row.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

15 REPLIES 15
mangaus1111
Solution Sage
Solution Sage

Like in this example

mangaus1111_0-1667902068592.png

 

Thanks, but it still returns the total number of all rows back to each main customer number. Maybe I do something wrong.

You need to create a measure, not a colum

Hi @Power_BI_Adapt ,

can you send me a screenshot of your wrong result?

Herewith a screenshot:

 

Power_BI_Adapt_0-1667913164454.png

 

'Hoofd klantnummer' = Main customer number and 'Aantal afleverklantnummers' = Number delivery customer numbers'.

'Hoofd klantnummer' is soueced from table 'Dim Klant' en 'Aantal afleverklantnummers' is a measure written in the following way:

Aantal afleverklantnummers = COUNTROWS('Dim Afleverklant')
 
Table Dim Afleverklant is containing the delivery customer number

Hi @Power_BI_Adapt ,

do you have a 1 to many relationship between Dim Klant  and Dim Afleverklant?

if you send me a sample file with no sensitive data I can try to give you further help

Hi @Power_BI_Adapt ,

try to delete this row from your Delivery Table

mangaus1111_0-1667985301056.png

 

In my file the measure is working. If you want I can send you my file

mangaus1111_0-1667986479350.png

 

Thanks. If you could send your file, I will appreciate.

@mangaus1111: yes, true, a one to many relationship (Dim Klant (1) to Dim Afleverklant (many).

mangaus1111
Solution Sage
Solution Sage

Hi @Power_BI_Adapt ,

I think you can use simply the measure COUNTROWS('Table') and put it in matrix with the Main Customer Number column in the row.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It works!

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.