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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MiaRose
Frequent Visitor

Trouble with counting and grouping for one table

Hi

 

I have one table of data that has a row per user who has received an item. A user can receive multiple items.

 

What I'm trying to do is have counts of the number of items each user can have, so from 1 to 60, say, and then how many users have only one item, or 25 items.

 

So something like:

  • Item Count | Users
  • 1 | 50
  • 2 | 25
  • 3 | 10

Etc. 

 

I'm having trouble forumatling the calculated columns / measures to achieve this.

 

Any help would be appreciated. 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @MiaRose,

 

Not sure what is your desired output, here are two ways for your reference.

 

Suppose your table structure is like below:

1.PNG

 

1.  Create two measures.

Count measure =
CALCULATE (
    DISTINCTCOUNT ( 'Item-User'[Item] ),
    ALLEXCEPT ( 'Item-User', 'Item-User'[Users] )
)

Have 1 item =
CALCULATE (
    COUNT ( 'Item-User'[Users] ),
    FILTER ( ALL ( 'Item-User' ), [Count measure] = 1 )
)

Add corresponding fields into table visual.

2.PNG

 

2. Create a calculated column in source table.

Count = CALCULATE(COUNT('Item-User'[Item]),ALLEXCEPT('Item-User','Item-User'[Users]))

Create an extra table to lists all available count item values (from 1 to 60), like this:

3.PNG

 

Then, create a one to many relationship between these two tables.

4.PNG

 

Use a table visual to display data records.

5.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
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

3 REPLIES 3
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @MiaRose,

 

Not sure what is your desired output, here are two ways for your reference.

 

Suppose your table structure is like below:

1.PNG

 

1.  Create two measures.

Count measure =
CALCULATE (
    DISTINCTCOUNT ( 'Item-User'[Item] ),
    ALLEXCEPT ( 'Item-User', 'Item-User'[Users] )
)

Have 1 item =
CALCULATE (
    COUNT ( 'Item-User'[Users] ),
    FILTER ( ALL ( 'Item-User' ), [Count measure] = 1 )
)

Add corresponding fields into table visual.

2.PNG

 

2. Create a calculated column in source table.

Count = CALCULATE(COUNT('Item-User'[Item]),ALLEXCEPT('Item-User','Item-User'[Users]))

Create an extra table to lists all available count item values (from 1 to 60), like this:

3.PNG

 

Then, create a one to many relationship between these two tables.

4.PNG

 

Use a table visual to display data records.

5.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

Show the data and the expected result.


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

The data is highly sensitive, so showing the actual data isn't a possibility. I'll see if I have time to dummy up fake data that may mimic it. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors