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
Anonymous
Not applicable

Count of Count

Hi all,

 

I am trying to get a count of a count.

 

Sample data:

 

PERSON_IDUSE_ID
1333
1444
1555
2666
2777
3888
4999
51111
52222
53333
54444

 

At the moment I am counting the number of 'USE_ID' for each PERSON_ID', so

 

  • PERSON_ID 1 has a count of 3 USE_ID,
  • PERSON_ID 2 has a count of 2 USE_ID
  • PERSON_ID 3 has a count of 1 USE_ID
  • PERSON_ID 4 has a count of 1 USE_ID
  • PERSON_ID 5 has a count of 4 USE_ID

I am trying to make a measure that will show me the count of these counts, e.g:

 

1 PERSON_ID with 4 USE_ID,

1 PERSON_ID with 3 USE_ID,

1 PERSON_ID with 2 USE_ID,

2 PERSON_ID with 1 USE_ID.

 

The logic would then ideally be used so I can have:

 

Total of PERSON_ID with 1 USE_ID, 2-3 USE_ID, 4-5 USE_ID, 6-9 USE_ID, 10+ USE_ID.

 

Thanks!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try to create a new table

table2 = SUMMARIZE('Table','Table'[PERSON_ID],"count",count('Table'[USE_ID]))

right click the personID column and select count

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

 

1. Create a measure: Count of 'USE_ID' for each PERSON_ID'.

Count of 'USE_ID' for each PERSON_ID' = COUNT('Table'[USE_ID])

count1.PNG

2. Create a table.

Num of count of USE_ID = 
SUMMARIZE (
    GENERATESERIES (
        1,
        MAXX ( VALUES ( 'Table'[PERSON_ID] ), [Count of 'USE_ID' for each PERSON_ID'] ),
        1
    ),
    [Value],
    "No. of USE_ID", [Value] & " USE_ID"
)

num.PNG

 

3. Create a measure: Count of PERSON_ID with n USE_ID.

Count of PERSON_ID with n USE_ID = 
VAR t =
    ADDCOLUMNS (
        'Table',
        "count1", CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[PERSON_ID] ) )
    )
VAR t2 =
    ADDCOLUMNS (
        t,
        "count2", CALCULATE (
            DISTINCTCOUNT ( 'Table'[PERSON_ID] ),
            FILTER ( t, [count1] = MAX ( 'Num of count of USE_ID'[Value] ) )
        )
    )
RETURN
    IF (
        HASONEVALUE ( 'Num of count of USE_ID'[No. of USE_ID] ),
        MAXX ( t2, [count2] ),
        DISTINCTCOUNT ( 'Table'[PERSON_ID] )
    )

count2.PNG

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try to create a new table

table2 = SUMMARIZE('Table','Table'[PERSON_ID],"count",count('Table'[USE_ID]))

right click the personID column and select count

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@amitchandak  I'm finding this very difficult to understand after reading all the articles.

 

They all seem to related to the value within the column and not a count of that value appearing next to another column, like in my initial post.

 

Please can you elaborate on which article of the multiple articles applies to my example, and how?

 

dwidrascuBG_0-1597678378924.png

Here is my visualisation with the count of USE_ID against the PERSON_ID. I want to group these but when I right-click, group cannot be selected and is greyed out.

 

Please can there be some further assistance here? The prior steer is insufficient, unfortunately after reading the articles I still don't quite understand.

 

Thanks.

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.

Top Solution Authors