# Using variables to get previous values

This has been driving me a bit crazy all day - and on the face of it should be a simple thing to achieve but I simply cannot get my head around it

To set the scene, I am working using Direct Query and therefore have various restrictions in the way I can try to implement this. What I need is to use a previously calculated measure and figure out the movement made in that measure from one month to the next

My date table is a period table with a single row per month (first day) and the PTR calculation uses the work % complete to figure out what profit can be taken in a given period

You can see from the below table that currently my previous PTR measure matches the current PTR

This is the measure code for the previous PTR measure

I am trying to set a variable that fixes the Calculated PTR and then returns the previous value so that I can then compare the two values and simply calculate the change

I just cannot figure it out - yet it seems like something that should be so simple

Does this technique answer this perfectly for you

I think it should.

Give it a go.

Chrs
Sam

1 Like

Hi Sam

Thanks for the pointer

This method got me to the required result (eventually)

I realised that as my Calculated PTR measure was actually a result of multiple branched measures it was actually the root level measures that I needed to apply this this technique to.

Therefore I had to create â€śpreviousâ€ť measures against each of my underlying measures to monitor the prior values that could then be summed up at the top project level. Seems very messyâ€¦but it worksâ€¦ FINALLY

Thanks again - really appreciate it

Dave

Brilliant, thatâ€™s great.

Chrs

Hi Shawn,

great to have you here and posting for the first time.

It would be best if you post this as a new topic, perhaps include the link to this post/thread for reference purposes, as this post is solved.

It will mean you have more chance of this being answered as it will not show under a solved post.

David

Will do - thanks for the quick reply

1 Like

No problem, I meant to add if youâ€™re able to add a PBIX also that would be a big help.