Forum Discussion

gulzatsirenova's avatar
gulzatsirenova
Regular Visitor
6 years ago

Calculation based on previous value in calculated coloumn/advanced recursive calc

Hello, gurus!

 

I am trying to calculate "Total quality", based on combination of previous rows including the calculated column itself:

 

i:  Mass:   Quality:   **bleep** Mass:  Total quality

1) 100       1             100             100*1/100=1

2) 50         2             150             (100*1+50*2)/150=1.33

3) 50         3              200            (150*1.33+50*3)/200=1.75

4) -100                     100            1.75

5) 80        2               180            (1.75*100+80*2)/180=1.86

Basically: 

Total quality (i)= if positive, then [**bleep** mass (i-1)*Quality (i-1)+Mass(i)*Quality(i)]/**bleep** Mass(i); if negative, then Total quality (i-1).

 

I went to through some articles, and seems like handling recursive calcuation is not straightforward in DAX. But I thought I would give it a try, and maybe there is some workaround. Any workaround helps (either through calculated column, or measure, or power query).

 

Thanks in advance!