Forum Discussion
Recursive Measure PowerBI
Hi All,
I would like to calcul : Stock Month -1+ Entrées Prév - Sorties Prév for each row(row = month)
The Column "Sorties Prev" is a measure in link with few measures.
I add a measure : ForecastCalculation =
VAR PrevInv = CALCULATE(SUMX('Simulation StockDP (2)'; 'Simulation StockDP (2)'[Stock]); DATEADD(DateTable[Date]; -1; MONTH))
RETURN (PrevInv + SUMX('Simulation StockDP (2)'; [Entrées Prév - Sorties Prév]))
The line for February is good, but for March the resulat is note good because the stock egals 0.
For March, i would like to calculate : Stock February + Entrées Prev - Sorties Prév (6673+2576-2693)
For April, i would like to calculate : Stock March+ Entrées Prev - Sorties Prév (6556+1730-2474)
For May, ....
Please , help me.
Thanks a lot.
5 Replies
- Greg_DecklerCommunity Champion
DAX does not generally like recursion. See the article:
https://community.powerbi.com/t5/Community-Blog/Runge-Kutta-and-the-Limits-of-DAX/ba-p/357501
However, I wrote a blog article recently that might help with your situation:
https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/ba-p/636314
Could you post sample data as text and expected output? Would help tremendously.
- PdecisFrequent Visitor
I would like this :
Stock = 7316 (january)
Stock for February = Stock January (7316)+Entrées-Sorties
Stock for March = Stock February + Entrées + SortiesIn Power BI, Sorties ia a measure link with few measures.
....
Thanks- Greg_DecklerCommunity Champion
Hmm, well I gave this a lot of thought. Not sure I have what I need from a sample data perspective to give you a detailed solution, but I did come up with a way to emulate recursion in DAX that might work for your purposes. See here: