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
rsanyoto
Helper III
Helper III

Calculate distinct count occurence

Hi guys,

 

I have a simply question. i have a table with customers that have created sales in a period of time. My goal is to distinct count  how many of customer created a sales transaction in a period. For examole this customer created two sales transaction in 2020. the column measure calculate now:

Measure = CALCULATE(
DISTINCTCOUNT('Sales'[CustomerKey]),
FILTER(ALL('Sales'),'Sales'[CustomerKey] = EARLIER('Sales'[CustomerKey])))
 
 
2021-03-23 16_54_54-MI Dashboard - Power BI Desktop (May 2020).png
 
Its return now 2 as total but i want to only display value 1 as result. any suggestion to change my cuurent measure?

 

 

many thanks

 

1 ACCEPTED SOLUTION

Hi @amitchandak ,

 

thanks for your quick response... your proposal result in each row a 2 . To return 1 for each row and as Total the solution that i tested is:

 

CALCULATE(
DISTINCTCOUNT('Sales'[CustomerKey]),
FILTER(ALLSELECTED('Sales'),'Sales'[CustomerKey] = MAX('Sales'[CustomerKey])))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@rsanyoto , Try a measure like

 

Measure = CALCULATE(
COUNT('Sales'[CustomerKey]),
FILTER(ALLSELECTED('Sales'),'Sales'[CustomerKey] = MAX('Sales'[CustomerKey])))

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

Hi @amitchandak ,

 

thanks for your quick response... your proposal result in each row a 2 . To return 1 for each row and as Total the solution that i tested is:

 

CALCULATE(
DISTINCTCOUNT('Sales'[CustomerKey]),
FILTER(ALLSELECTED('Sales'),'Sales'[CustomerKey] = MAX('Sales'[CustomerKey])))

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