If i've actual sale by week rolling, I would to filter only product have actual sales last 12 week. How can i create work flow.
A | 01.2018 | 948941 |
A | 02.2018 | 2222543 |
A | 03.2018 | 8004863 |
A | 04.2018 | 7784038 |
A | 05.2018 | 6197539 |
A | 06.2018 | 7886544 |
A | 07.2018 | 7379607 |
A | 08.2018 | 2203715 |
A | 09.2018 | 3017844 |
A | 10.2018 | 7679522 |
A | 11.2018 | 6518827 |
A | 12.2018 | 1265694 |
A | 13.2018 | 9018866 |
A | 14.2018 | 7543925 |
A | 15.2018 | 23512 |
A | 16.2018 | 2200521 |
A | 17.2018 | 6433105 |
A | 18.2018 | 8700647 |
A | 19.2018 | 3666616 |
A | 20.2018 | 7613239 |
A | 21.2018 | 5974221 |
A | 22.2018 | 6188258 |
A | 23.2018 | 577347 |
A | 24.2018 | 7344316 |
A | 25.2018 | 6207304 |
B | 01.2018 | 0 |
B | 02.2018 | 0 |
B | 03.2018 | 0 |
B | 04.2018 | 0 |
B | 05.2018 | 9852260 |
B | 06.2018 | 6414161 |
B | 07.2018 | 2599728 |
B | 08.2018 | 2169699 |
B | 09.2018 | 2241194 |
B | 10.2018 | 6817776 |
B | 11.2018 | 2637558 |
B | 12.2018 | 6232087 |
B | 13.2018 | 7809928 |
B | 14.2018 | 6034553 |
B | 15.2018 | 6722189 |
B | 16.2018 | 5351556 |
B | 17.2018 | 9596153 |
B | 18.2018 | 2150359 |
B | 19.2018 | 2574456 |
B | 20.2018 | 1763329 |
B | 21.2018 | 8610813 |
B | 22.2018 | 5532745 |
B | 23.2018 | 5560542 |
B | 24.2018 | 271180 |
B | 25.2018 | 6968067 |
C | 05.2018 | 0 |
C | 06.2018 | 0 |
C | 07.2018 | 0 |
C | 08.2018 | 0 |
C | 09.2018 | 0 |
C | 10.2018 | 0 |
C | 11.2018 | 0 |
C | 12.2018 | 0 |
C | 13.2018 | 0 |
C | 14.2018 | 0 |
C | 15.2018 | 0 |
C | 16.2018 | 0 |
C | 17.2018 | 0 |
C | 18.2018 | 0 |
C | 19.2018 | 0 |
C | 20.2018 | 0 |
C | 21.2018 | 5260949 |
C | 22.2018 | 284634 |
C | 23.2018 | 2215067 |
C | 24.2018 | 8766827 |
C | 25.2018 | 8390595 |
from the above table to the below table.
A | 14.2018 | 7543925 |
A | 15.2018 | 23512 |
A | 16.2018 | 2200521 |
A | 17.2018 | 6433105 |
A | 18.2018 | 8700647 |
A | 19.2018 | 3666616 |
A | 20.2018 | 7613239 |
A | 21.2018 | 5974221 |
A | 22.2018 | 6188258 |
A | 23.2018 | 577347 |
A | 24.2018 | 7344316 |
A | 25.2018 | 6207304 |
B | 14.2018 | 6034553 |
B | 15.2018 | 6722189 |
B | 16.2018 | 5351556 |
B | 17.2018 | 9596153 |
B | 18.2018 | 2150359 |
B | 19.2018 | 2574456 |
B | 20.2018 | 1763329 |
B | 21.2018 | 8610813 |
B | 22.2018 | 5532745 |
B | 23.2018 | 5560542 |
B | 24.2018 | 271180 |
B | 25.2018 | 6968067 |
Solved! Go to Solution.
So, first things first, lets generate a column which is just the week number. This can be achieved using a string formula along the lines of...
tonumber(left([FieldB],2))
Let's save this as a new field called 'week' and convert the data type to 'double'
Let's repeat this step now for year, something along the lines of
tonumber(right([FieldB],4))
should suffice. Again lets save this as a new field called 'Year' and convert the data type to 'double'.
Next we need a method for isolating the last date, this can be done in many ways. I would use a sort tool, to sort your data by 'year' and then 'week' (it's key that it is in this order).
Now a final step we can use is to sample our data. Let's sample the last '12' records (because we want to look back 12 weeks. And in order to do this for each group, we must group on [FieldA].
This will leave us with 36 records. 12 records for A, 12 records for B and 12 records for C (you seem to be missing this from your output but I'm guessing that was by accident).
I've attached the sample solution for you.
Ben
Thank you for you solution but it can't solve my issue. I would to filter only which product have actual sales last 12 week only. if some last 12 week don't have actual sales i would to filter out because that are new product.
@ponraj be careful here, as we are working with dates you need to remember that if we go into 2019 the weeks will likely restart at 01.2019 and so on.
In your situation if we have say 5 weeks from 2019 and then all of our 2018 data. The 2018 data will be selected as 52.2018 is selected as the latest date, which is not true. Your generate rows method would also fall down too.
Ben
@winnie12 can you clarify your point.
So if a product has say data from weeks 18 to week 25, it should not be shown because there are not 12 weeks of data?
Ben
I've attached an ammended workflow to cater for the additional business rule you wanted.
This time I summerize to find the last year and last week. I then use the generate rows tool (in a similar way to ponraj) to identify the 12 weeks we need to look for.
I then join this against our initial data stream.
By then performing a count for each product of the number of records, if it is equal to 12 we want to keep the product, if it is not then it must be a new product.
See attached.
Ben
Attaching updated workflow for your case after correcting the fault which @BenMoss highlighted. Hope it helps.,
as i use your idea simulate with real data. i found some of data that i would to filter out still showing.
May i explain what i would again.
1) I've actual sales rolling by week.
2) I would to filter out which product don't have actual sales some rolling last 12 week. if one of 12 month don't have actual sales supposed to be filter out also. I would only product have actual sales 12 week.
Filter in :
- product that have actual sales > 0 for all last 12 week
- product that have actual sales between week in last 12 week (w1-4 = value, w5-7 = 0, w8-12 = value)
Filter out:
- product that have actual sales = 0 since first week until some of 12 week ( ex. w1 = 0, w2 = 0, w3 = 4, w3-12 = value)
- example data need to filter out in screenshot.
Could you try and take the solutions provided by @ponraj and myself and have an attempt at applying the business logic you have identified, given the solutions provided I'm sure you could attempt to ammend them to meet your requirements.
Once you have had an attempt then let us know where you are stuck!
Ben