Alteryx Designer Desktop Discussions

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

Filter data

winnie12
7 - Meteor

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.

 

A01.2018948941
A02.20182222543
A03.20188004863
A04.20187784038
A05.20186197539
A06.20187886544
A07.20187379607
A08.20182203715
A09.20183017844
A10.20187679522
A11.20186518827
A12.20181265694
A13.20189018866
A14.20187543925
A15.201823512
A16.20182200521
A17.20186433105
A18.20188700647
A19.20183666616
A20.20187613239
A21.20185974221
A22.20186188258
A23.2018577347
A24.20187344316
A25.20186207304
B01.20180
B02.20180
B03.20180
B04.20180
B05.20189852260
B06.20186414161
B07.20182599728
B08.20182169699
B09.20182241194
B10.20186817776
B11.20182637558
B12.20186232087
B13.20187809928
B14.20186034553
B15.20186722189
B16.20185351556
B17.20189596153
B18.20182150359
B19.20182574456
B20.20181763329
B21.20188610813
B22.20185532745
B23.20185560542
B24.2018271180
B25.20186968067
C05.20180
C06.20180
C07.20180
C08.20180
C09.20180
C10.20180
C11.20180
C12.20180
C13.20180
C14.20180
C15.20180
C16.20180
C17.20180
C18.20180
C19.20180
C20.20180
C21.20185260949
C22.2018284634
C23.20182215067
C24.20188766827
C25.20188390595

 

from the above table to the below table.

 

A14.20187543925
A15.201823512
A16.20182200521
A17.20186433105
A18.20188700647
A19.20183666616
A20.20187613239
A21.20185974221
A22.20186188258
A23.2018577347
A24.20187344316
A25.20186207304
B14.20186034553
B15.20186722189
B16.20185351556
B17.20189596153
B18.20182150359
B19.20182574456
B20.20181763329
B21.20188610813
B22.20185532745
B23.20185560542
B24.2018271180
B25.20186968067
14 REPLIES 14
ponraj
13 - Pulsar

Attaching a sample workflow for your case. Hope this helps. 

 

WorkflowWorkflowResultsResults

BenMoss
ACE Emeritus
ACE Emeritus

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).

 

Sample.png

 

I've attached the sample solution for you.

 

Ben

 

 

 

 

winnie12
7 - Meteor

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.

 

 

BenMoss
ACE Emeritus
ACE Emeritus

@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

BenMoss
ACE Emeritus
ACE Emeritus

@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

BenMoss
ACE Emeritus
ACE Emeritus

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.

 

2018-06-15_10-35-02.png

 

See attached.

 

Ben

ponraj
13 - Pulsar

Attaching updated workflow for your case after correcting the fault which @BenMoss highlighted.  Hope it helps., 

 

workflow.PNG

winnie12
7 - Meteor

@ponraj@BenMoss

 

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.

 

 

Pic.png

BenMoss
ACE Emeritus
ACE Emeritus

@winnie12

 

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

Labels