Hi Steve I could find a way to do it. Any quick sample and syntax?
List of the rows with the first occurrence of each distinct name:
filter( "example", ( [_rownumber] = min( select( example[_rownumber], ([_thisrow-1].[name] = [name]) ) ) ) )
[_thisrow-1] in the SELECT() expression refers to the row being examined by the enclosing FILTER() expression.
[_thisrow] (without the
-1), were it present, would still refer to whatever row the FILTER() expression was being evaluated for, as normal.
The slice row filter equivalent to the above would be:
( [_rownumber] = min( select( example[_rownumber], ([_thisrow].[name] = [name]) ) ) )
What’s the point of “after” values? I’ve never understood why I would use that?
@Steve Could we now do double dereference?
In this article we read that this is not possible. (under " Double Dereference Expressions")
Let’s say we have 3 Tables:
In the Grandchild Table we want to get a value from the Parent Table.
s the article says, we need to create an extra VC in the Child Table and use this VC like a Bridge between the Parent and Child Table.
Could we now use something like [_thisrow-2].[Parent Name] in the Grandchild Table?
I tested a bit but with no luck.
But that would be very helpful and would save the world from too many VCs
Not to my knowledge. _THISROW-n is not a work-around for dereference chains.
Back-references within nested queries ([_THISROW-n])
Consider a complex App formula with “nested” SELECT() expressions (SELECT() expressions within SELECT() expressions):
SELECT( table[column1], ... SELECT( table[column2], ... SELECT( table[column3], ... ) ... ) ... )
Let’s call the row for which this entire expression is evaluated as its App formula the Origin Row.
Within this entire expression, we can refer to column values of the Origin Row by dereferencing
[_THISROW]. For instance, to get the value of the Customer Name column of the Origin Row, we can use
Let’s also name each of the nested queries within the entire expression:
SELECT(table[column1], ...)(outer-most query)
SELECT(table[column3], ...)(inner-most query)
Query 2 is nested inside Query 1. Within Query 2, column values of the row currently being examined by Query 1 can be accessed by dereferencing
[_THISROW-1]. For instance, to get the value of the column1 column of the Query 1 row, we can use
_THISROW-1 refers to the query one step outside the current query.
Query 3 is nested inside Query 2.
[_THISROW-1] refers to the query one step outside the current query, so within Query 3,
[_THISROW-1] refers to the current row of Query 2. Query 2 is itself nested within Query 1, so Query 1 is two steps outside Query 3.
[_THISROW-2] can be dereferenced to access the values of columns in the query two steps otside the current one: Query 1.
I’ve been trying to figure out a good use case, but I was struggling with the concept. But that chart makes it super easy. I hope you can add that image to the support docs at some point.
I hope to at some point. In the meantime, I’ve added a link to that reply to this FAQ’s index so it’ll have some prominence here.
Come to think of it. Images similar to this would probably help in several of the support docs detailing some of the more complex stuff.
So to get the NEXT TO LAST or PENULTIMATE row would this work?
MAXROW( "My Table", "_ROWNUMBER-1", ([_THISROW]-1.[Thing] = [Thing]) )
INDEX( ORDERBY( FILTER( "My Table", ([_THISROW].[Thing] = [Thing]) ), [_ROWNUMBER], TRUE ), 2 )
Hey @Steve… You’ve expressed a complex thing with succinct elegance here… I’ve been struggling to grasp the ([_thisrow-n]) concept but I get it now… Cheers…
Thanks a lot for this @Steve
Where should this expression be entered to have a unique list of rows?
I have a table with multiple columns. I wanted to have a unique list of rows for the following:
- list of unique values from [service towers] under [segment].
- list of unique values from [list transactions] under [service towers] under [ segment].
The list I hope to use in an interactive dashboard. Values will change after selecting [service towers] and [list transactions].
This is my first app and would appreciate all the guidance you can give.
Where should this code go? I tried entering this to slice but the result should be yes and no so it didn’t accept.
Is there any way to select maximum occurred value from the list of columns from List([col.1],[col.2],[col.3],[col.4],[col.5],…)
Maybe column 1 Have apple, Column 2 have Orange, Column 3 have again Apple so display “Apple” as its occurred more times than orange ?
Not to my knowledge.
Having similar values across several columns - especially to the point that you would want to count them - is a red flag indicator that you are probably not using the correct table design/structure for your app.
Appsheet is a row-based system, as are most data systems. It is best to use a normalized structure which simply put means you store the data as rows instead of columns so it can easily be processed as the system intended.
To expand on your example. Let’s say your table has columns Fruit1, Fruit2, Fruit3, Fruit4, Fruit5…etc. As soon as you have more fruit than columns, you have an issue. You would need to expand the table with more Fruit columns. But how many more? This is a non-normal form. You can’t know how many columns you need ahead of time. Couple that with the fact that there are no functions to help you count, sum, etc by columns and you will find that there is great difficulty building the app.
Instead, you would want to normalize the data, by creating a structure like so:
Item-Number Fruit 1 apple 2 orange 3 apple 4 kumquat 5 tangerine
This represents the same data, even the column numbers, but as rows.
By normalizing the data, you can add countless rows with no need to change the data structure. And you can then use the system functions to easily select rows for counting, summing ect. Life will be much better!!
I hope this helps!
Thanks a lot for your time.
I need to do like column only because I have few criterias and each column have 3 options that is selected from the table like you mentioned above. But for my requirement I need almost 11 column and each column Is different criteria like priority, price, item type etc… but everything has a table that is listed and selected using select function.