Extract and display the last element in an Array

Hey Gliders :wave:,

I would like some assistance with finding and displaying the last element in an array.

Some context:
I have created an array using the make array column. The columns that make up this array column are “if then else” columns. I am using this if then else columns to help locate specific documentation within the client’s company. An example is when a certain paper is passed from the clerk to the invoice clerk, they have to enter a passcode and if this matches then the "if then else column will say “The document is with Invoice Clerk”. The invoice clerk would then work with this document and then hand it over to another member of the team and the same procedure of passcode and then “if then else” is used.

Now I made an array column of all these “If then else” columns with the hope of extracting the last element of the array and then displaying this as the last seen location of the document for easy tracking of the document within the firm.

I hope this makes sense and someone knows how I can achieve this and of there is an easier way of constructing this logic, please do let me know. It would be highly appreciated :pray:

EDIT:

What I have done thus far is I reversed the array and then sliced it to grab the first element. This seems to work so far but I don’t know if this is the best way of doing it or there is a better way. So please do share if anyone thinks of something better in the meantime…

Now I am battling with displaying this. How do I display this information (Sliced -Reversed Array) on the front end?

You could achieve this using Single Value column. There’s an option to get the last value of a list or an array.

But the array is made up of different “If then else columns”. I had to first create an array of these different status updates of the documents then extract only the last update…
I don’t see how the single value can help unless I am missing a trick…

Let me try and expand further on what I want to achieve…

If then else 1: the document is with the driver

If then else 2: the document is now with the clerk

ITE 3: the document is now with the invoice clerk

Array: ITE1; ITE2; ITE3

Therefore what I want to display is "Document last seen: ITE1/2/3 depending on the stage of the whole process…

How can I use the single value for this? I may be missing something…

You just need to point the single value column direct to the array column. Pick the array column directly. Don’t choose the table->array. The array column should be at the very top of the list of columns to choose from.

Another alternative would be to skip the array altogether and just create another IF column that looks at all of your other IF columns, but in reverse order.

3 Likes

With regards the ITE column in reverse order…
I just want to check that I understand you…

It would be "IF ITE3 is empty then ITE2 and then further “IF ITE2 is empty then ITE1”…etc?

IF ITE3 is not empty then ITE3
IF ITE2 is not empty then ITE2
IF ITE1 is not empty then ITE1
ELSE blank

2 Likes

Thanks so much @Jeff_Hager & @11183

The single value did the trick :grinning::raised_hands:

Much appreciated :pray:

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.