Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

sum upto last n dates data

PKN
6 - Meteoroid

Hi all,

 

I am new to the Alteryx and searching for help to solve the following problem.

 

The sample data looks like:

itemdateQtySum_Qty_21_days
A27/11/2019512
B22/11/201934
D29/10/201923
E10/11/201911
F25/11/201927
C25/11/201917

The column Sum_Qty_21_days should contains the sum of Qty of last 21 days. e.g. Sum_Qty_21_days field for date 27/11 have value 12 because of sum of column Qty for dates 27/11, 22/11, 10/11 and 25/11 (for both item F and C). Similarly, Sum_Qty_21_days field for date 22/11 have value 4 because of sum of column Qty for dates 22/11 and10/11.

Note: Same date can have multiple rows, sum should consider multiple dates too.

 

First priority is to perform this with In-database tools only, if not possible, solution with other tools are welcome too. 

 

Thanks in advance.

6 REPLIES 6
OllieClarke
15 - Aurora
15 - Aurora

Hi @PKN This workflow does what you want not in-db. My output is slightly different to yours, but I believe it is correct. I'm not an expert in in-db, so I don't know how you would do the generate rows part of the workflow in-db. If you can work that out, then all the other steps are simple in-db.

OllieClarke_0-1574862647883.png

 

Hope that helps,

 

Ollie

Dazzerman
11 - Bolide

Hi @PKN 

 

I see that @OllieClarke beat me to it!

 

I have attached how I achieved a solution to your problem.

 

I hope this helps.

PKN
6 - Meteoroid

Thanks a lot for the solution @Dazzerman. The solution is correct and working for sample data but I am getting error "The value did not change after the Loop Expression", Although, I am getting an output but it is not correct as some dates are missing. I tried a lot but couldn't identify the reason. May be my sample data doesn't adhere to whole data. Actually, I just want to add the Qty for last 21 days for same item. Like this:

itemQtyDateSum_21_Days
A32019-10-119
A52019-10-086
A12019-10-053
A22019-09-154
A12019-09-092
A12019-09-011
B32019-10-118
B22019-10-085
B32019-10-054
B12019-09-155
B42019-09-094
C12019-10-114
C22019-10-083
C12019-10-052
C12019-09-156
C02019-09-095
C42019-09-015
C12019-08-281

 

Sorry for the inconvenience. It would be very helpful of you if you can help me with this.

 

Thanks.

PKN
6 - Meteoroid

Hey, I have solved the error, it was because of null values. Thanks a lot to both of you. Really appreciate your quick response.

Dazzerman
11 - Bolide

Nice one!

 

I had time to run your updated data through my copy of the workflow and didn't get an error, then had to go to a meeting so couldn't investigate further. Glad you found the problem and have your solution.

PKN
6 - Meteoroid

No worries. You already helped me enough 🙂 Your solution was applicable for new sample data set also but my whole data set was different from sample data set in terms of date null values, that's why I was getting the error. But, all solved now. Thanks again.

Labels