Forum Discussion

ChouaibBenali's avatar
ChouaibBenali
New Member
2 years ago
Solved

Math Wizadery Recursion

Hi everyone, i looked arround and since i'm no math guru i really need help coming up with a solution for this problem, i need to replicate this logic: 

 JanuaryFebruary  MarchApril
Sell Out    17 014 679,20    16 188 004,97    22 978 536,89    20 032 740,21
Sell In    19 980 043,44    20 248 217,04    24 824 416,44    21 868 254,12
Estimation Stock       2 965 364,24       7 025 576,31       8 871 455,86    10 706 969,77

 
So Estimation Stock for January is just Sell In - Sell Out but for Feburay it's (Sell In - Sell Out) + Estimation Stock of January

I tried to come up with 3 measures to do that but no luck so far, kinda stuck actually, i dunno if the problem is algorithmic as it seems that it needs Recursion or there's a simple workarround that i'm not able to see, here's the 2 Dax Measures that i wrote for it:

This measure calculates the differance 

A =
VAR CurrentMonthSellOut = [Total des ventes secondaire en litre OUTSB] -
VAR CurrentMonthSellIn = [Sell IIn Reel 1]
RETURN
    CurrentMonthSellIn  - CurrentMonthSellOut


Estimation Stock =
VAR CurrentMois= SELECTEDVALUE('Période'[TheDate].[NoMois])
VAR PreviousMonthEstimationStock= CALCULATE([Estimation Stock],PREVIOUSMONTH('Période'[TheDate]))
RETURN
       IF( CurrentMois = 1,  [A], 
PreviousMonthEstimationStock + [A] 
          )

Obviously this will not run as it is self referencing itself,it's just to help you understand the logic.


Can anyone help me about it ?

  • Hi ChouaibBenali ,

     

    We can calculate the cumulative Sell-In minus the cumulative Sell-Out, and hopefully the following expression will inspire you.

     

     

     

    Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

     

    Thank you~

2 Replies

  • Hi ChouaibBenali ,

     

    We can calculate the cumulative Sell-In minus the cumulative Sell-Out, and hopefully the following expression will inspire you.

     

     

     

    Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

     

    Thank you~

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    ChouaibBenali Generally recursion is not possible. However, in your case you may be able to get around that limitation by creating a measure for Previous Month Estimation Stock, Current Month Estimation Stock and your A measure.