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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Value from last week

Hello all,

 

I'm trying to collect whatever the value is from last week within a custom column. Below is an example of what it would look like

 

table.PNG

 

I've started the DAX code but currently this only turns blank fields: 
VAR
most_recent_date = LASTDATE('data'[date]) -7


VAR Calc = CALCULATE(
SELECTEDVALUE('data'[rollingRate]),
FILTER(ALL('data'), FORMAT('data'[date], "dd/mm/yy") = FORMAT(most_recent_date, "dd/mm/yy") ))

RETURN

Calc


Thanks in advance for any help!!
 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Remember that you have to calculate this from the point of view of the visual element if you do this as a measure.

 

So instead of 

VAR most_recent_date = LASTDATE('data'[date]) -7

 

you would say

VAR most_recent_date =DATEADD('data'[date]), -7,DAY)

 

Note that "the value from last week"  is not the same as "the value from the day seven days before the current day"

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hello @Anonymous 

 

shwetadalal_0-1635582852492.png

Please see if the following query.

 

Prev Week Sales =
LOOKUPVALUE('Table'[Sale Value],'Table'[Date],DATEADD('Table'[Date],7,DAY))
 
Hope this helps.
Kindly accept it as a solution if it satisfies your requirement.
lbendlin
Super User
Super User

Remember that you have to calculate this from the point of view of the visual element if you do this as a measure.

 

So instead of 

VAR most_recent_date = LASTDATE('data'[date]) -7

 

you would say

VAR most_recent_date =DATEADD('data'[date]), -7,DAY)

 

Note that "the value from last week"  is not the same as "the value from the day seven days before the current day"

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.