BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Augusto
Obsidian | Level 7

 Hello,

 

I wroted a question that was solved and i'm very grateful for this. (Using the previous result line to calcute the next)

 

Now, I still in problem with a new calculating.

 

I have to calculate a result using the previous result.

 

HAVE:

segment month safra qt_account_initial attrition_a attrition_b perc_affluent
varejo 30/06/2019 1 100 2,00% 2,00% 10,00%
varejo 31/07/2019 2 100 2,00% 2,00% 10,00%
varejo 31/08/2019 3 100 2,00% 2,00% 10,00%
affluent 30/06/2019 1 80 2,00% 2,00% 0,00%
affluent 31/07/2019 2 80 2,00% 2,00% 0,00%
affluent 31/08/2019 3 80 2,00% 2,00% 0,00%

 

WANT:

 

segment month safra qt_account_initial attrition_a attrition_b perc_affluent new_acc_initial acc_whitout_attrition_a acc_whitout_attrition_b acc_whitout_affluent qt_add_affluent
varejo 30/06/2019 1 100 2,00% 2,00% 10,00% 100,00 98,00 96,04 86,44 9,60
varejo 31/07/2019 2 100 2,00% 2,00% 10,00% 86,44 84,71 83,01 74,71 8,30
varejo 31/08/2019 3 100 2,00% 2,00% 10,00% 74,71 73,22 71,75 64,58 7,18
affluent 30/06/2019 1 80 2,00% 2,00% 0,00% 89,60 87,81 86,06 86,06 0,00
affluent 31/07/2019 2 80 2,00% 2,00% 0,00% 94,36 92,47 90,62 90,62 0,00
affluent 31/08/2019 3 80 2,00% 2,00% 0,00% 97,80 95,84 93,92 93,92 0,00

 

TO CALCULATE THE NEW COLUMNS: 

new_acc_initial     

acc_whitout_attrition_a 

acc_whitout_attrition_b 

acc_whitout_affluent 

qt_add_affluent

 

Condition for the first iteration : IF SAFRA EQ 1 THEN new_acc_initial = qt_account_initial;

 

NOTE: The trick is to add the qt_add_affluent result when its filled into the affluent segment line

1 ACCEPTED SOLUTION
1 REPLY 1