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
raodil
New Member

Dax query for previous day value

Hi,

i am writing a measure to find the value based on previous day date. the measure is as follows but it is not displaying the previous day value.

 

weight_prev =
 var prev_date='QUERY3-sensorid_dupl'[refdate_prev]
 VAR weight_prev_value =  CALCULATE ('QUERY3-sensorid_dupl'[weight], 'QUERY3-sensorid_dupl'[REFDATE]=prev_date)
return weight_prev_value
4 REPLIES 4
Dangar332
Super User
Super User

Hi, @raodil 

 

i am not sure but try below

var prev_date='QUERY3-sensorid_dupl'[refdate_prev]

VAR weight_prev_value =  CALCULATE ('QUERY3-sensorid_dupl'[weight], filter('QUERY3-sensorid_dupl','QUERY3-sensorid_dupl'[REFDATE]=prev_date))

return weight_prev_value

 

 

Hi,

 

Nothing is getting displayed , just blank 😞

i can see the prev day date coming but it is not filtering the value based on the previous day date.

tackytechtom
Super User
Super User

Hi @raodil ,

 

I think, you need to remove the filter context. Does it work like this?

weight_prev =
 var prev_date='QUERY3-sensorid_dupl'[refdate_prev]
 VAR weight_prev_value =  CALCULATE ('QUERY3-sensorid_dupl'[weight], ALL('QUERY3-sensorid_dupl'), 'QUERY3-sensorid_dupl'[REFDATE]=prev_date)
return weight_prev_value
 
Let me know! 🙂



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi Tom, 

 

thanks but it is not working 😞

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.