# Last value previous month

Hi,

I’ve created a calculation which gives me the last value on a month basis but I need a measure to show me the last value for the previous month as I need to show the delta between the two.

So I need to know how to shift Life Miles Last Value back to the previous month

I haven’t posted a PBIX as I thought this might be relatively simple fix but if you need a PBIX let me know and I’ll cobble one together.

``````Life Miles Last Value =
VAR _LastDateWithMiles = MAX ( Assets[Snapshot Date] )
VAR Result =
CALCULATE (
[Life Miles],
'Date'[Date] = _LastDateWithMiles
)
RETURN
Result
``````

Any assistance, as always, gratefully accepted.

DJ

Hello @DavieJoe,

Thank You for posting your query onto the Forum.

Since you want to evaluate the last value of the previous month. Can you please try the below provided measure?

``````Life Miles Last Value =
VAR _LastDateWithMiles =
LASTDATE( PREVIOUSMONTH( Assets[Snapshot Date] ) )

VAR Result =
CALCULATE ( [Life Miles] ,
'Date'[Date] = _LastDateWithMiles )

RETURN
Result
``````

Hoping you find this useful and meets your requirements that you have been looking for.

Thanks and Warm Regards,
Harsh

2 Likes

@Harsh That’s great, much appreciated, works perfectly.

I tried a few different ways to no avail, but the simplicity of your solution is great. Your answer has been a great piece of learning, thank you. I was applying to the shift of dates incorrectly to the calculate also

DJ

1 Like

Hello @DavieJoe,

You’re Welcome.

I’m glad that was able to assist you and you find the solutions helpful in your learning.

Thanks and Warm Regards,
Harsh

1 Like

Hello @DavieJoe,

Today, I came across one of the post over LinkedIn and I think you’ll find this one very helpful while evaluating or shifting the date contexts in your measures. Below is the link of the post provided for the reference.

Hoping you’ll find this post helpful for future references.

Thanks and Warm Regards,
Harsh

1 Like

Thanks Harsh, very kind, I did spot this on LinkedIn and I saved it down for later reading.

I will check it out.

DJ

1 Like