Give a number value based on where the item falls in a list?

I need an expression to help me place a value of the items in a list.  

The List:

This list is in order of least to greatest (Based on location distance).  I need to put a value (starting with the number 1 ) going up for each item in the list.

My list:

Tiger1_0-1698942219693.png

Column I need to add the values of each of these items.  Again the value will be a number according to where they are in this list.

For example,

From the list above the first number (40123404) would get the value "1",  The number (40123431) would get the value "2", and so on.....

0 9 279
9 REPLIES 9

Could you update how will you mention the item (40123404) or (40123431) and so on? Through a column value?

In general you are looking for INDEXOF() function that does not exist in AppSheet but @Steve has shared an excellent expression for the same in the tip below

INDEXOF() - Google Cloud Community

In general, you expression will be as follows

COUNT(
SPLIT(
ANY(
SPLIT(
(" , " & [EnumList] & " , "),
(" , " & [Enum] & " , ")
)
),
" , "
)
)

 Please substitute your list values/column in place of Enumlist and the value whos index you are looking for in the list at [Enum]

So in your to find "40123404" , the expression will be something like

COUNT(
SPLIT(
ANY(
SPLIT(
(" , " & [Closest Item] & " , "),
(" , " & "40123404" & " , ")
)
),
" , "
)
)

 

Yes.  Here is the column I have to put that number/value:

Tiger1_0-1698943098179.png

 

 

Okay , then it will be 

COUNT(
SPLIT(
ANY(
SPLIT(
(" , " & [Closest Item] & " , "),
(" , " & [Value of Item] & " , ")
)
),
" , "
)
)

Thank you.

Wait I realized I did't ask or say everything I need it to look at:

I need this expression to look at a value and determine where that value sits in this list.  

My table looks like this fully:

Tiger1_1-1698943765086.png

I need this expression to give the number value of where the [Inventory ID] column falls in the list of [Closest Item].  Then place that value/number in the column [value of item]

 

I tried using that expression, but it simply puts the last value (in my case "8") for each row:

Tiger1_0-1698943650588.png

 

 

 

 

I think you may need to give more precise example. In the examples you have shared the inventory ID is 8 digit number and the list has all the elements preceded by 7 0s before the actual digits start. 

Also invariably in the list,  the inventory ID is always sitting at the first place in the list with those 7 leading zeros added. So the index value will always be one.

Suvrutt_Gurjar_0-1698945041318.png

Could you share for each row what result you are expecting. Are you expecting to disregard those leading zeros in the list and search for inventory ID? And any specific reason the inventory id is sitting always at the first place in the list ( with of course those 7 leading zeros added) ?

 

 

 

Yes.  Again I apologize.  I know I don't say everything correctly.  So I have a table that I populate.  My goal is to get this table to show me in order (based on location - GPS) the list.  I have this column [closest item] that I populate based on this expression:

TOP(
ORDERBY(
FILTER("GeoForce",
AND(
[Branch] = "19-01",
[Status] = "On-Rent",
[Category] = "Pumps")
),
DISTANCE(
[LATLONG],
LATLONG([Lat], [Long])
)
),
30
)

 

Geoforce table - has these items that I get this info from.  I need to get these items in an order from closest to furthest to help our drivers route their daily driving.

So, I was trying to get the list and then automatically order the items based on their gps/location.

 

The above expression I wrote is making the first item [inventory ID] show up.  I wish it would NOT do that.  But I am unsure How to take it out.  Also, the leading zeros - that is because I have to add preceeding zeros as I am comparing different tables.  In those two different tables - some have zeros some don't.  So I match them by adding zeroes to BOTH.  Does that make sense?

 

 

This is what I need it to do - In red:

Tiger1_0-1698952086113.png

 

 

 

Thank you. Based on the latest screenshot you have shared, please try an expression as follows  in the [Value of item] column

COUNT(
SPLIT(
ANY(
SPLIT(
(" , " & [Closest Item] & " , "),
(" , " & "0000000"&[Inventory Id] & " , ")
)
),
" , "
)
)

 

In general, I believe you will need to have this column [Value of item]  as VC if the list [Closest Item] can change with new added values etc. With real column the change may not reflect, unless the record is edited. 

If this is the goal.. "I need to get these items in an order from closest to furthest to help our drivers route their daily driving", why don't you add a virtual column which calculates the DISTANCE() based on the driver's location. It's then calculated every time when the driver syncs the app and it shows the closest location if you sort the view with the distance.

Top Labels in this Space