Matrix calculated based on the previous value

18 views Asked by At

I've been struggling with a problem for a while now and I could really use some help.

I need to recreate this table.

What I need to do

The first column is a fairly simple formula, and the subsequent columns are calculated by taking the value from the previous column, corresponding to the previous month, except for the first month which uses the value from the first column.

Other matrix needed

We need "Ouverture N" and "Fermeture N"

So, I've created the necessary measures to calculate this table, but I can't figure out how to retrieve the previously calculated value. The formula should be something like:

For example for the 2nd of 2024 month you should do 387 +616 - 236 = 767 For the 1st month of 2023 ex : 2276 + 189 - 612 = 1853

If 1st month : Stock + Ouverture N - Fermeture N

Else : First tab(n-1) + Ouverture N - Fermeture N.

Any assistance would be greatly appreciated! Thank you in advance.

Here is the pbix file if needed : https://1drv.ms/u/s!AkVb3v9gSRNFrCpbE4ZkrwC4qypW?e=gsW4wT

I only did the first column of the needed matrix because it's only Stock + Ouverture - Fermeture, but I didn't find how to get the last value, I was looking for like a "LAG" function but seems not to exist in DAX.

0

There are 0 answers