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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Yesterday based on filter vs Any day of sales based on selection

Hi guys,

 

I need to calculated yesterday's data based on date slicer vs any day in the past based on user's selection

 

Yesterday will be always given from the date slicer, for example if the user put 11/11/2020 (the value will be from 10/11/2020)

 

I have worked out the yesterday's calculation which is:

Sales Yesterday =
CALCULATE( [Sales], FILTER(ALL('Date'), 'Date'[Date] = MAX('Date'[Date])-1)
 
Then I need somehow to calculate the sales from yesterday vs any specifc day that the user select.
 
Do I need to create another date table? the user needs to have the ability to select a secondary date the sales from that date vs yesterday.
 
the trick is that yesterday's measure should be based on the date filter selection, like
max date -1
 
 
Any thoughts?
 
Thanks all
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 
You can use selectedvalue() and -1, to get the day before the selected date. 

 

Measure = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),[Date]=SELECTEDVALUE('Table'[Date])-1))

Example:
V-pazhen-msft_0-1607998658522.png

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Anonymous 
You can use selectedvalue() and -1, to get the day before the selected date. 

 

Measure = CALCULATE(SUM('Table'[Sales]),FILTER(ALL('Table'),[Date]=SELECTEDVALUE('Table'[Date])-1))

Example:
V-pazhen-msft_0-1607998658522.png

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

S_JB
Resolver III
Resolver III

You could alter your measure for yesterday's sales so that a slicer isn't needed, then create a new measure which pulls back sales from the selected date in a slicer.

 

For yesterday's sales you could use this logic:
Sales Yesterday = CALCULATE(SUM([Sales]),Date=TODAY()-1)

 

You could then use logic similar to the below to pull back the date selected in your slicer:

Date Selected Sales = 
CALCULATE(SUM([Sales]),FILTER(ALLSELECTED([Date].[Date]),Date.Date<=MAX(Date.Date)))

Anonymous
Not applicable

Hi,

the problem that i can see in this solution is that my yesterday's measure must be dinamic regarding to the date filter as well

If the user select 10/11 the it should be 09/11 and so on.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors