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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.