Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Commulative Sum: Not RUNNING TOTAL

aman_goyal
8 - Asteroid

Hello Community,

I am unable to implement one scenario in Alteryx, Please provide me solution for below scenario:

We have table having field RATE, using that need to implement new field called FACTOR. In which need to required add previous rows and multiply with RATE. 

 

I tried to implement in Alteryx using Multi-row formula like:

Step1: Add Record ID.
Step2: Multi-Row Formula-

IF [RecordID]=1
THEN ROUND(([RATE]*100),.01)

 

ELSE ROUND(([RATE]*(100-[Row-1:FACTOR])),.01)

ENDIF

 

But I am not getting the same results required.

 

PFA data and field calculation (FACTOR) in excel that needs to implement in Alteryx.

 

 

6 REPLIES 6
Luke_C
17 - Castor

Hi @aman_goyal 

 

I was able to do this with an iterative macro. It will calculate one row at a time and pass the previous rows calculations back in which are summarized for use in the current calculation. Let me know if you have any questions. 

 

Luke_C_0-1666890206751.png

 

Luke_C_1-1666890224203.png

 

ShankerV
17 - Castor

Hi @aman_goyal 

 

The below formula was failing because of the highlighted one.

 

Step1: Add Record ID.
Step2: Multi-Row Formula-

IF [RecordID]=1
THEN ROUND(([RATE]*100),.01)

 

ELSE ROUND(([RATE]*(100-[Row-1:FACTOR])),.01)

ENDIF

 

In the above you are just using only last FACTOR to subtract from 100, but you need to sum all the above factor and detect.

 

You can refer to the @Luke_C solution as he derived it for you when I was also trying to reach the result for you.

Thanks @Luke_C. You are lighting fast.

aman_goyal
8 - Asteroid

Thank you @Luke_C, It works.
But there is one problem, there is one more field named ID, need to do group by that ID. I have tried that but result is not coming correct. In the below screenshot for row 3 it should be:
For RecordId=1, RATE*(100-0.06),
But it is taking (RATE*(100-(0.06+4.37))

PFA files. Can you please help me with this?

aman_goyal_2-1666960889863.png

 


Also I did not understand the use of yellow box part. Can you please guide me with this?

aman_goyal_1-1666957539512.png





Also, Is there any other way to do the same without using Macros?

aman_goyal
8 - Asteroid

Thank you @Luke_C, It works.
But there is one problem, there is one more field named ID, need to do group by that ID. I have tried that but result is not coming correct. In the below screenshot for row 3 it should be:
For RecordId=1, RATE*(100-0.06),
But it is taking (RATE*(100-(0.06+4.37))

PFA Alteryx files and updated Input file. Can you please help me with this?

aman_goyal_0-1666961791715.png

 

 


Also I did not understand the use of yellow box part. Can you please guide me with this?

aman_goyal_1-1666961791844.png

 





Also, Is there any other way to do the same without using Macros?

Luke_C
17 - Castor

Hi @aman_goyal 

 

Here's a way to batch it by ID. For the part you highlighted, that is the iterative output of the macro. When working with iterative macros it needs to have a way to know when to stop iterating. In this case, I'm using the record ID field as way to control what record is being processed based on what number iteration it's on. By finding the max record ID we also know what the last iteration number should be. By filtering on Max Record ID >= Iteration, we ensure that once the iteration becomes greater than the record ID no records will pass through the filter, stopping the macro. 

 

Luke_C_0-1666964071232.png

 

 

aman_goyal
8 - Asteroid

Thank you @Luke_C 

It is working!! 

Labels