Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Dynamically filter records after a certain keyword

Csam
6 - Meteoroid

Good morning,

 

I have many data sources all coming into Alteryx from excel. The important info for my data always starts on rows 1, 2 or 3  but this changes occasionally. More importantly the information always starts after a record with the word "Cost" or "Price", like so:

 

   
   
CostAB
123456789
   

 

or

   
PRICEAB
545565546
   

 

Rather than changing a select record tool for each new sheet, is there a tool which could detect the keywords "Cost" or "Price" and filter only for the records after?

 

Thank you!!

3 REPLIES 3
jdunkerley79
ACE Emeritus
ACE Emeritus

I suggest using a multi row formula tool to create a new column you can use to filter:

clipboard_image_0.png

 

IIF([Row-1:FilterMe],1,IIF([Field1] IN ('Cost', 'Price'),1,0))

 

The filter value will stick to True once it has encountered either Cost or Price

 

Sample attached

estherb47
15 - Aurora
15 - Aurora

Hi @Csam 

Take a look at this approach. I mocked up some more data, where the headers aren't always "Cost" or "Price". All credit to @jdunkerley79 for getting the creative process flowing with his great solution, and thought to create a boolean field for filtering.

image.png

The multi-field formula tool takes a couple of passes at each row of data, using the following function:

 

IF IsEmpty([Field1]) THEN 0
ELSEIF [Field1] in ("Cost","Price") THEN 0
ELSEIF [Row-1:Field1] in ("Cost","Price") THEN 1
ELSEIF [Row-1:FilterMe]=1 THEN 1
ELSE 0
ENDIF

 

So first, if it's an empty row from your data (here, I've assumed you're unioning the Excel files together), mark it with false. Same if the row contains the words "Cost" or "Price", because those are just headings. Then, if the row above has Cost or Price in the first column, or the FilterMe field in the row before is true, then mark it as true. 

 

Otherwise it must be false. This works for many different headings, and for when there are blank rows separating the data (or there aren't blank rows). 

If your empty rows contain spaces, you can replace the first line with Contains([Field1]," ")

Let me know if this helps.

 

Cheers!

Esther

Csam
6 - Meteoroid

This is exactly what I was looking for, thank you both for the help!!

Labels