Forum Discussion
quarterpenny
7 years agoFrequent Visitor
Distinct Count with Cumulative Measure filter
Trying to get a distinct count of category per year, but only where the cumulative value up to the end of the year is NOT zero. See data below. e.g the distinct count of Category at the end of 20...
v-juanli-msft
7 years agoCommunity Support
Hi quarterpenny
Modify with this
create a column year = YEAR(Sheet1[Date]) create measures Measure = CALCULATE(MAX(Sheet1[Date]),FILTER(ALLEXCEPT(Sheet1,Sheet1[Category]),Sheet1[year]=MAX(Sheet1[year]))) Measure 2 = CALCULATE(SUM(Sheet1[Value]),FILTER(ALLEXCEPT(Sheet1,Sheet1[Category]),Sheet1[Date]<=MAX(Sheet1[Date])&&Sheet1[Date]<=[Measure])) Measure 3 = SUMX(FILTER(ALLEXCEPT(Sheet1,Sheet1[Category]),Sheet1[year]=MAX(Sheet1[year])&&Sheet1[Date]=[Measure]),[Measure 2]) Measure 4 = CALCULATE(DISTINCTCOUNT(Sheet1[Category]),FILTER(ALL(Sheet1),Sheet1[year]<=MAX(Sheet1[year]))) Measure 5 = CALCULATE(DISTINCTCOUNT(Sheet1[Category]),FILTER(ALL(Sheet1),Sheet1[year]<=MAX(Sheet1[year])&&[Measure 3]=0)) Measure 6 = [Measure 4]-[Measure 5]
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.