Limit rows using a column from related table

Ray
New Member

For the following statement - which is the start of a report - can I limit the number of Customer records that are displayed according to a setting in the related Orders table.

Open Orders Report <<NOW()>>

<<Start:SELECT(Customers[CustomerName], true,true)>>
Customer

Customer Name: <<[CustomerName]>>

The related table Orders has a column named Invoiced. Can I get this SELECT statement to only show records where [Orders][Invoiced] = FALSE?

Thank ou

0 10 337
10 REPLIES 10

For sure. Please review this article for how to use SELECT statements.

And a bonus tip; always use FILTER instead of SELECT inside a START. FILTER is equivalent to SELECT( Table[key-column] โ€ฆ ) and you will never not be wanting to return a list of key values inside of START.

So in total:

<<START: FILTER( Customers , xxxx .....

Oops, I got this far without realizing a major detail about your question. Iโ€™ll leave the above still, perhaps just edit it for later:

How many Order records do you have per Customer? Do you want the customer to be shown in the workflow/report if a single Order recordโ€™s [Invoiced] column is FALSE. Or if all of them, or what exactly?

There can be several orders for the customers in the filtered list. But I only want to track the items that have not been invoiced so Iโ€™m not concerned about any orders that have been invoiced. If several orders appear in the list for a customer they should all match the FALSE condition (not invoiced).

When you say โ€œshouldโ€, are you saying that if one Customer has multiple Orders, they will always all be either invoiced or all not-invoiced?

It would be possible for a customer to have both invoiced and non invoiced orders within a billing cycle. The purpose of this report is to catch the uninvoiced records.

Ok it sounds like youโ€™re going to want nested START expressions.

Weโ€™ll start with the outer START expression to only select customers that have ANY non-invoiced Orders

Then the inner START expression will select only the related Orders that are non-invoiced.

<<START: FILTER( Customers , IN( FALSE , [Orders][Invoiced] ) )>>
##customer details display here##

<<START: SELECT( [Orders][key-column] , NOT( [Invoiced] ) )>>
##order details display here##

<<END>>

<<END>>

Oh yah, I just violated my bonus tip from above, haha. I used a SELECT in the inner START, but thatโ€™s because Appsheet doesnโ€™t allow you to use a Virtual List of Refs type column ( i.e. [Orders] ) inside of a FILTER.

How does the relationship between Orders and Customers get established? Does the system make the connection automatically?
And what type of list is generated?
Shouldnโ€™t the output from the OUTER expression be a list of Orders?

The outer START expressions puts the workflow into the context of each Customer record, iteratively. The inner START then uses the related order virtual column which is already limited to only the Orders for each Customer.

START expressions always require a list of key values. Beyond that Iโ€™m not sure what this question means.

I donโ€™t know. I was only guessing at what you need. You perhaps need to further explain your end goal.

Sounds like you may need to review this help article:

I really appreciate your patience. Iโ€™m having a hard time getting my head around the concept of the nested expressions. I will review the article youโ€™ve suggested and then give my brain a rest . Perhaps it will make more sense in the morning.

Be safe and thanks again.
Ray

Sure.

The suggestion above would produce an output similar to the following:

Customer A
    Order #768
    Order #982
Customer B
    Order #45876
Customer D
    Order #32375
    Order #20200

Where all displayed Orders are non-invoiced, and where a โ€œCustomer Cโ€ does not have any non-invoiced Orders, and thus is not listed. Is that what youโ€™re wanting?

Exactly what I was looking for. But frustrating because I cannot get the conceptโ€ฆ Iโ€™ll keep working through it.

Great to have your assistance.

Ray

Top Labels in this Space