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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Dailem
Frequent Visitor

Distinct Count with Filter- Year Minus 1,2

I'm trying to get a distinct count of accounts that are filtered to only include accounts with Amount > 0.  The measure below gives me that count based upon the existing slicer quarter that I have selected (I have a Calendar in my model, but then a reporting calendar which only shows quarter-end dates).  So my report is filtered to 9/30/2023, for example:

Measure1 =

CALCULATE(
DISTINCTCOUNT(Table1[AccountKey]),
FILTER(Table1, Table1[Amount] > 0))

 

...however, I am trying to look at this same measure one year ago, two years ago, etc..  I have another measure that looks at prior year sales by filtering using the following in a calculate function:

dateadd('Calendar'[Date],-1,year)

 

...I have tried to add a second filter, but I cannot seem to get it to work properly.  When it does work, it only returns the existing date distinct counts- not those from the prior year.  How can I add a date filter on top of my existing Measure1 above to return the prior year account counts?  Any help is greatly appreciated!!

 

1 ACCEPTED SOLUTION
Dailem
Frequent Visitor

I was able to resolve this on my own.  The way that I was able to get the result was to use the initial measure in a second measure.  So first measure is:

 

 

Measure1 =

CALCULATE(
DISTINCTCOUNT(Table1[AccountKey]),
FILTER(Table1, Table1[Amount] > 0))

 

...second measure is

Measure2 = 

CALCULATE(Measure1, dateadd('Calendar'[Date],-1,year))

 

...this returns the same distinct count of the accountkey column, but does so for the prior year.  Thanks for all who responded!!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Dailem ,

Can you provide some example data that can be used to more clearly articulate the problem you are experiencing.  Please provide more details with your desired out put and pbix file without privacy information.

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but please try creating the semantic model's relationship between Calendar Table and Fact Table by using Calendar[Date] column, not Calendar[QuarterEndDate] column.


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.
Dailem
Frequent Visitor

I was able to resolve this on my own.  The way that I was able to get the result was to use the initial measure in a second measure.  So first measure is:

 

 

Measure1 =

CALCULATE(
DISTINCTCOUNT(Table1[AccountKey]),
FILTER(Table1, Table1[Amount] > 0))

 

...second measure is

Measure2 = 

CALCULATE(Measure1, dateadd('Calendar'[Date],-1,year))

 

...this returns the same distinct count of the accountkey column, but does so for the prior year.  Thanks for all who responded!!

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

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!

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.

Users online (25)