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

Distinct Values with date filter

Hi,

I would like some help in displaying distinct values for a specified period of time. 'DISTINCT COUNT' works seamlessly without a filter applied. For example let's say I would like to see distinct shops visited in week 35, I should be able to see ShopE only since ShopB and ShopD have been visited in week 29 and week 34 respectively.

Any advice how this can achieved?

Shop_idShop_nameDate_VisitedWeek_No
100ShopA14/7/2029
101ShopB15/7/2029
102ShopC22/7/2030
103ShopD17/8/2034
100ShopA21/8/2034
102ShopC13/8/2033
106ShopE29/8/2035
101ShopB23/8/2035
103ShopD25/8/2035
101ShopB14/9/2038
1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@Kaskazi_Network

Here is an alternative (table name 'ShopVisits'):
1) Measure to use in the filter panel to filter a table

Distinct visits = 
VAR PrevVisit = CALCULATETABLE(VALUES(ShopVisits[Shop_name]), 
                FILTER(ALL(ShopVisits[Week_No]), 
                ShopVisits[Week_No] < SELECTEDVALUE(ShopVisits[Week_No])))
VAR Selected = VALUES(ShopVisits[Shop_name])
RETURN
COUNTROWS(EXCEPT(Selected, PrevVisit))

2) measure to list the new stores visited:

New Shops visited = CONCATENATEX(FILTER(ALL(ShopVisits[Shop_name]), 
                    [Distinct visits] = 1), 
                    ShopVisits[Shop_name], ", ")

And you understand this:

Result.JPG





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
PaulDBrown
Community Champion
Community Champion

@Kaskazi_Network

Here is an alternative (table name 'ShopVisits'):
1) Measure to use in the filter panel to filter a table

Distinct visits = 
VAR PrevVisit = CALCULATETABLE(VALUES(ShopVisits[Shop_name]), 
                FILTER(ALL(ShopVisits[Week_No]), 
                ShopVisits[Week_No] < SELECTEDVALUE(ShopVisits[Week_No])))
VAR Selected = VALUES(ShopVisits[Shop_name])
RETURN
COUNTROWS(EXCEPT(Selected, PrevVisit))

2) measure to list the new stores visited:

New Shops visited = CONCATENATEX(FILTER(ALL(ShopVisits[Shop_name]), 
                    [Distinct visits] = 1), 
                    ShopVisits[Shop_name], ", ")

And you understand this:

Result.JPG





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






That worked perfectly for me, thanks
Greg_Deckler
Community Champion
Community Champion

@Kaskazi_Network Maybe something like the following?

Measure = 
  VAR __Min = MIN('Table'[Date])
  VAR __Max = MAX('Table'[Date])
RETURN
  COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(ALL('Table')[Date_Visited]>=__Min && [Date_Visited]>=__Max),"Shop_name",[Shop_name])))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Kaskazi_Network , Try a measure like

Assume a week is selected

 

countx(values(Shop_id) , if(distinctcount(Table[Week_No]) ,calculate(distinctcount(Table[Week_No]) , filter(all(Table), Table[Week_No]<=selectedvalue(Table[Week_No])))<=0, blank(),1))

 

Best is that you move week to week table

and try like

countx(values(Shop_id) , if(distinctcount(Table[Week_No]) ,calculate(distinctcount(Table[Week_No]) , filter(all(Week), Week[Week_No]<=selectedvalue(Week[Week_No])))<=0, blank(),1))

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

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