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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

Click here to schedule a short Teams meeting to discuss your question.
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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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