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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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()))

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.