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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DISTINCTCOUNT FOR MEASURES (YTD CALCULATION)

Hello All,

 

I have a certain number of customers and currently i have MTD calculation, in this case usually DISTINTCOUNT works pretty well: i add the function + column, and it's done.

But as second calculation i need "YTD customers". I need to apply DISTINCTCOUNT to an existing measure, not to a column, but it doesn't work.

 

Is there any other function which same proposal (ignore repetitians) which could be applied to measures?

 

Thanks for your help.

1 ACCEPTED SOLUTION
Adescrit
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

You can't apply DISTINCTCOUNT over a measure.

 

I'm using the below formulas and it works:

 

Total OB EUR Customers = DISTINCTCOUNT( Sales[Customer Id] )

Total OB EUR YTD Customers = CALCULATE( [Total OB EUR Customers], DATESYTD( dCalendar[Date] ) )

 

Because the # customers measure is already calculating the distinct count of cutomers, you can just calculate that measure without having to re-calculate a distinct count.


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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hello @Adescrit.,

 

I already applied DISTINTCOUNT as prior calculation to my measures, but as i mentioned at the beginnining, now i have a YTD calculation, and for this one i need to remove the repetitions since there're the same customers in different months.

"Total OB_EUR Customers" is a distinctcount measure, and now i have to apply YTD + DISTINCTCOUNT as you see below, but how? there's no way to divide it by parts.

ANE2CAbo_0-1660556652007.png

 

Adescrit
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

What is the current formula you're using to try to calculate the YTD customers?

 

Could you repeat the calculation you're using to calculate the number of customers, but then add a filter condition for YTD?

 

Something like this:

YTD Customers = 
CALCULATE( DISTINCOUNT( 'Customers'[ID] ), DATESYTD( Date[ Date ] ) )

 

This requires you to have a date dimension table (Date[Date]) and the Customers[Id] is your  list of customers so replace as necessary.


Did I answer your question? Mark my post as a solution!
My LinkedIn
Anonymous
Not applicable

Hello @Adescrit,

 

i'm using exactly this formula, but as you wrote "Customers [ID]" is a column, and i have a measure, which doesn't work for this kind of function.

  It doesn't work for measures:

ANE2CAbo_0-1660553820565.png

 

Thanks.

Adescrit
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

You can't apply DISTINCTCOUNT over a measure.

 

I'm using the below formulas and it works:

 

Total OB EUR Customers = DISTINCTCOUNT( Sales[Customer Id] )

Total OB EUR YTD Customers = CALCULATE( [Total OB EUR Customers], DATESYTD( dCalendar[Date] ) )

 

Because the # customers measure is already calculating the distinct count of cutomers, you can just calculate that measure without having to re-calculate a distinct count.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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