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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Milan14
Frequent Visitor

Distinct Count of USERID by Date

Hi All,

 

I would like to calculate the distinct count of USERID by DATE and CUSTOMER TYPE for Year-to-Date (1/1/2021 – 5/1/2021).

 

Sample table:

Milan14_0-1634804271601.png

 

Expected outcome in the table:

Milan14_1-1634804298847.png

 

Expected outcome in matrix table:

Milan14_2-1634804326034.png

 

Any help would be much appreciated.

 

Thanks in advance!

 

Kindly Regards,

Milan

 

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Distinct count userid : =
IF (
HASONEVALUE ( Data[type] ),
COUNTROWS ( DISTINCT ( DISTINCT ( Data[userid] ) ) ),
SUMX (
ALL ( Data[date], Data[type] ),
CALCULATE ( COUNTROWS ( DISTINCT ( Data[userid] ) ) )
)
)
 
Distinct count userid by type only: =
IF (
HASONEVALUE ( Data[type] ),
SUMX (
ALL ( Data[date] ),
CALCULATE ( COUNTROWS ( DISTINCT ( Data[userid] ) ) )
),
SUMX (
ALL ( Data[date], Data[type] ),
CALCULATE ( COUNTROWS ( DISTINCT ( Data[userid] ) ) )
)
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

amitchandak
Super User
Super User

@Milan14 ,

Try a measure like

 

calculate(sumx(summarize(Table, Table[Date], Table[Customer Type], "_1", distinctcount(Table[UserID]) ), [_1]), datesytd('Date'[Date]))

 

datesytd , in case you need ytd

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

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.