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! Learn more

Reply
chulpanvl
Helper I
Helper I

Count unique ids conditional on another column

Hello everyone!

 

I have a table with «user id» column which contains the participants of lotteries and «event type» column which is an id of a lottery. "Event type" takes values from 0 to 3. A user can participate in the lottery multiple times. I want to get a percentage of users participated in the lottery «3» who also participated in at least one of other lotteries (0,1,2). The solution must be simple but somehow I cannot make it work. Hope to get some hints here.

 

Thank you!

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @chulpanvl 

 

You can try this measure 

UserCount 3 & Other = 
var user_type_count_table = SUMMARIZE('Table','Table'[user_id],"Number_Of_Types",DISTINCTCOUNT('Table'[event_type]))
var user_type_3 = SUMMARIZE(FILTER('Table','Table'[event_type]=3),'Table'[user_id])
var user_type_3_and_other_count = COUNTROWS(FILTER(user_type_count_table,[Number_Of_Types]>1&&[user_id] IN user_type_3))
return
user_type_3_and_other_count

vjingzhang_0-1643881858952.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @chulpanvl 

 

You can try this measure 

UserCount 3 & Other = 
var user_type_count_table = SUMMARIZE('Table','Table'[user_id],"Number_Of_Types",DISTINCTCOUNT('Table'[event_type]))
var user_type_3 = SUMMARIZE(FILTER('Table','Table'[event_type]=3),'Table'[user_id])
var user_type_3_and_other_count = COUNTROWS(FILTER(user_type_count_table,[Number_Of_Types]>1&&[user_id] IN user_type_3))
return
user_type_3_and_other_count

vjingzhang_0-1643881858952.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@chulpanvl , Try a measure like


countx(filter(summarize(Table, Table[User], "_1", countx(filter(Table, Table[lottery] =3),Table[lottery]), "_2", countx(filter(Table, Table[lottery] in {1,2,0}),Table[lottery])), not(isblank(_1)) && not(isblank(_2)) ), [User])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak! For some reason it counts every user id, not just filtered by "not(isblank(_1)) && not(isblank(_2))" condition. Could you pls help to elaborate it? Here is a pbix file to test. 

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