cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Regular Visitor

## Count of occurrences of distinct value A for distinct values within a table

Hi, I'm looking for some help with a DAX formula that would count the occurrences of a distinct value A for distinct values within a table. Regards Eamon

 Value A Required Dax formula to return the following values Distinct Values Yes/No Number of occurances of yes for each distinct value 5 Yes 1 4 Yes 1 4 No 1 3 Yes 2 3 Yes 2 1 Yes 2 1 Yes 2 1 No 2
1 ACCEPTED SOLUTION
Resident Rockstar

Hi @EamonC

You need a DAX Calculated column?

``````Column =
COUNTROWS(FILTER('Table','Table'[Distinct Values]=EARLIER('Table'[Distinct Values])&&'Table'[Yes/No]="Yes"))``````

3 REPLIES 3
Anonymous
Not applicable

Hey there,

I have the exact same problem, BUT I need the formula to create it as a measure instead of calculated column.

Since the EARLIER function as she is applied here is only working for calculated columns and not for measures, I tried following this blog post to translate the formula from the calculated column to a measure formula. Unfortunately without success.
This is my current state:

``````measure = CALCULATE(
COUNTROWS('Table'),
FILTER(ALL ('Table'), COUNTROWS(FILTER('Table', EARLIER('Table'[Distinct Values])='Table'[Distinct Values]&&'Table'[Yes/No]="Yes")
)
)
)``````
Every help is greatly appreciated 🙂
Best,
Peter
Super User
``Column = CALCULATE(COUNTROWS('fact'),'fact'[Yes/No]="Yes")``

Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Resident Rockstar

Hi @EamonC

You need a DAX Calculated column?

``````Column =
COUNTROWS(FILTER('Table','Table'[Distinct Values]=EARLIER('Table'[Distinct Values])&&'Table'[Yes/No]="Yes"))``````