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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Vaibhav_S
New Member

Count of distinct values of one column, grouped by values of another column

Hello Experts,

 

I am relatively new to PowerBI and have a query regarding counting distinct values and grouping them by values in another column.

 

 

I have a dataset with Customer ID's and the groups that they have shopped. 

I need a column which will return the number of different groups (unique groups) that each customer has shopped.

 

Sample dataset:

 

Customer IDGroup
A1Mercedes
A1BMW
A1Mercedes
A1Audi
A1BMW
A2Jaguar
A2Hyundai
A2Hyundai
A2Hyundai
A3Jaguar
A3Jaguar
A3Honda
A3Honda
A3Hyundai
A3Toyota

 

Sample Output:

 

Customer IDGroupOutput Column
A1Mercedes3
A1BMW3
A1Mercedes3
A1Audi3
A1BMW3
A2Jaguar2
A2Hyundai2
A2Hyundai2
A2Hyundai2
A3Jaguar4
A3Jaguar4
A3Honda4
A3Honda4
A3Hyundai4
A3Toyota4

 

Thanks !

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @Vaibhav_S - create a measure as below. it works

 

 

rajendraongole1_0-1727885124695.png

 

 

 

 

UniqueGroupsCount =
CALCULATE(
    DISTINCTCOUNT('carss'[Group]),
    ALLEXCEPT('carss', 'carss'[Customer ID])
)
 
or create a calculated column it works :
rajendraongole1_1-1727885257636.png

 

 

Hope this helps.





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

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @Vaibhav_S - create a measure as below. it works

 

 

rajendraongole1_0-1727885124695.png

 

 

 

 

UniqueGroupsCount =
CALCULATE(
    DISTINCTCOUNT('carss'[Group]),
    ALLEXCEPT('carss', 'carss'[Customer ID])
)
 
or create a calculated column it works :
rajendraongole1_1-1727885257636.png

 

 

Hope this helps.





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

Proud to be a Super User!





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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