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

Remove last n rows

akmuthu
7 - Meteor

1. How to remove last n rows with a single tool? Sample tool will retrieve last n rows, but doesn't remove last n rows right? 

 

2. Also, in terms of workflow constants, why and when do we use these engine constants? Can we multiple workflow constants in a single workflow? Thanks.

7 REPLIES 7
FinnCharlton
13 - Pulsar

Hi @akmuthu , 

There is a CReW Macro called "Skip Last N" that you can download here:

http://www.chaosreignswithin.com/p/macros.html

BS_THE_ANALYST
13 - Pulsar

Hey, to answer 1. You could use the Select Records tool!

 

BS_THE_ANALYST_0-1673969923597.png

 

binuacs
20 - Arcturus

@akmuthu I m not sure there is a single tool to remove the last N-Rows, but you can achieve this with couple of tools

 

binuacs_0-1673969908001.png

 

Christina_H
14 - Magnetar

Another option to remove the last N records would be to sort in reverse order then use a sample tool to skip first N records

Taylor_S
8 - Asteroid

Hello! 

To answer your first question, there are a number of ways you can skip the last N Rows with a single tool, however it somewhat depends on your workflow and the input. Let's say you have 5 records, and you want to skip the last 2 which are footer related. One way would be to just pull the first 3 using the First N Rows option of a Sample tool and setting N = 3. However, if the input is changing, meaning that the number of records can shift, this will become a problem and isn't the most dynamic solution as you may end up missing some data. Therefore, your best option would be to either to use multiple tools (such as a Sort Tool set to Descending order, followed by a Sample set to Skip 1st N Rows, and then followed once more by a Sort Tool set to Ascending order to revert the initial flip) or to download the Crew macro associated with skipping the last N rows. It all comes down to what you are trying to remove and if the dataflow input is going to be changing.

 

To answer your second question, engine workflow constants can be used a number of ways and honestly to list them all would make this post longer than it already is. But I can speak to my own most recent use at the very least. As a constant you will likely use these within Expression boxes found within tools like the Formula or Filter. Recently, I built a macro that, among other functions, sends an email to colleagues informing them that a particular workflow has been updated. For the email component, I built both the Body and Subject within a Formula tool as individual fields to be fed into the Email Tool. Using the WorkflowFileName constant within an expression ([Engine.WorkflowFileName] + " has been updated."), I was able to ensure that upon running, the macro pulls the outer workflow's file name (let's call it Workfow A) and places it within a corresponding message of both the subject and body fields (i.e. "Workflow A has been updated") so that the reader knows exactly what workflow changed. Now, regarding whether multiple can be used, I think that largely depends on how you are using them. For example, I could use the engine constant directed at workflow file name in multiple instances for something like a message in an email. But for something where perhaps you are manipulating Temp File paths or the workflow directory, you might want to be careful.

 

The following link gives a little more about the engine constants if you have interest: Constants | Alteryx Help

 

Again, this is just one way that an engine constant can be used. As I mentioned there are far more cases out there that could be discussed (many of which lie in realms of file inputs, outputs, pathing, etc) and I'm sure far more to come.  But hopefully this gives you some insight as to how they could be used. 

akmuthu
7 - Meteor

Hi @Taylor_S ,

 

That was a clear and wonderful explanation. Really appreciate your time and effort in making them clear! Thank you.

Taylor_S
8 - Asteroid

Glad I could help! Happy solving and let me know if I can be of any further aid! 

Labels