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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pradeepyadav921
Frequent Visitor

Yesterday and DayBefore Yesterday not changing with Date Picker

Hi all,

 

I have created a date picker and calculating yesterday and day and before yesterday for a particular data set but as a changes the date in the date picker it's not changing yesterday and day before yesterday value. Attached the DAX which I am writing for the day before yesterday and smiliar for yesterday. what should I do so that if we change the date in date picker the value of yesterday and day before yesterday also changes?  

 

Thanks in Advance.

pradeepyadav921_0-1711900502292.pngpradeepyadav921_1-1711900540744.png

 

1 ACCEPTED SOLUTION
FM-Rad10
Frequent Visitor

try this:

 

yesterday = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) )-1

day before yesterday  = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) )-2

View solution in original post

4 REPLIES 4
FM-Rad10
Frequent Visitor

try this:

 

yesterday = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) )-1

day before yesterday  = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) )-2

Chakravarthy
Resolver II
Resolver II

Hi @pradeepyadav921 

Create Measures as below:

 

Yesterday =
VAR _MAX = MAX('Table'[Date])
VAR _MIN = DATE(YEAR(_MAX),MONTH(_MAX),DAY(_MAX)-1)
RETURN _MIN
 
Day_Before_Yesterday =
VAR _MAX = MAX('Table'[Date])
VAR _MIN = DATE(YEAR(_MAX),MONTH(_MAX),DAY(_MAX)-2)
RETURN _MIN

It's giving 15 march as yesterday because 16 march is the last date in the dataset but I want that whatever date I select in the date picker suppose I select 13 march then yesterday and day before yesterday values changes to 12 march and 11 march

 

pradeepyadav921_0-1711907620035.png

 

@pradeepyadav921 

I am able to see the below

 

Chakravarthy_0-1711911519753.png

Chakravarthy_1-1711911553001.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.