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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Multiple date filters in calculatetable

Hi,
I saw this code snippet in a wokrshop held by Jeffrey Wang. The snippet defines a measure to calculate the number of returning customers  by date, in a very standard data model with sales, products and customers.

 

-----------------------

# NEW customers =
VAR vCustomersThisPeriod= VALUES(Appended_actuals[CustomerID])
var vCurrentdate = MIN('Date'[Date])
var VCustomersPreviousPeriod = CALCULATETABLE(VALUES(Sales[CustomerID]),
FILTER(ALL('Date'[Date]),'Date'[Date]<vCurrentdate),ALL('Date'[Date]))

Return COUNTROWS(EXCEPT(vCustomersThisPeriod,VCustomersPreviousPeriod))
-----------------------
 
My question is , why is there a need for the second ALL('Date'[Date]) in VCustomersPreviousPeriod?
Doesn't the first filter already accomplish the task?
Thanks a lot for the answers.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Good spot! This ALL(...) is not necessary. It serves no purpose, even though it's not harmful, either. The FILTER overwrites any filter present on the column anyway, so removing any filters via ALL is redundant.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Good spot! This ALL(...) is not necessary. It serves no purpose, even though it's not harmful, either. The FILTER overwrites any filter present on the column anyway, so removing any filters via ALL is redundant.

Anonymous
Not applicable

Hey daxer, thanks for the explanation!

 

Anonymous
Not applicable

Hi @amitchandak , thanks a lot for taking the time to answer, but I am not sure it responds to the question i had. In any case, it is much appreciated.

amitchandak
Super User
Super User

@Anonymous , I usually follow a measure approch

 

Current = sum(Table[Sales])

past =

Var _min = minx(allselected('Date'), Date[Date])

return

calculate(sum(Table[Sales]), filter(all('Date'), Date[Date] <_min)

 

 

new = countx(values(customer[Customer]), if(not(isblank([Current]))  && isblank([Past]) , [Customer], bank()))

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.