Last giving date

Hi everybody…

I try to create app has two tables:
Table#1 consist of 4 columns {[Barcode col, date col, Next giving date col, and ID col]} where:

[date column] type date= initial value TODAY()
[Next giving date] type date= [date column]+2.
[ID]= uniqueid()

Table#2 consist of 5 columns {[Barcode col, date col, Last giving date, Result, and ID col]} where:

[barcode] ref type with table#1
[date column] type date= TODAY()
[ Last giving date] type date= [Barcode].[Next giving date]
Result type text=
IFS([Date]=[Last giving date], Deserve, [Date]>[Last giving date], Deserve, [Date]<[Last giving date], Do not Deserve)
[ID]= uniqueid()

I have problem in Table#2 with [Last giving date] col.
where if there are several dates that record in Table#1 with same barcode So the [Last giving date] col. does not record the nearest last date to the present date, it is recording random date for example:
12/5/2020
14/5/2020
16/5/2020
I want the [Last giving date] col. should record 16/5/2020
but It is record 14/5/2020 or 12/5/2020.

thank you in advance…

Solved Solved
0 13 393
1 ACCEPTED SOLUTION

Okay… I see two problems.

  1. The Last giving date and Result columns of the checking_form table are normal columns with App formula expressions. App formula expressions for normal columns are only recalculated when the row is edited in a form or modified by an action. So while you may be adding more rows you expect those App formula expressions to see, they do not and will not until the checking_form row is modified by a form or an action. Consider using virtual columns for these two columns instead: virtual column values are recalculated automatically each time the app syncs.

  2. Your expression for the Last giving date column in the checking_form table dereferences the value of the Barcode column of the same row. The Barcode column is of type Ref and refers to the bread_distribution table. A Ref value by definition is the key column value of exactly one specific row in the referenced table. Based on the name of the Ref column, and your expressed expectations, I suspect you believe the value of the Barcode column of the checking_form table is a value in the Barcode column of the bread_distribution table. In fact, the Barcode value in the checking_form table is a value of the _ComputedKey column in the bread_distribution table.

To get the behavior you want, where Last giving date provides the latest value of the barcode’s Next giving date values and Result provides an up-to-date result, I suggest the following:

  1. In the checking_form table, change the column type of the Barcode column to Text.

  2. In the checking_form table, set the Valid_If expression of the Barcode column to:

    SORT(
      SELECT(
        bread_distribution[Barcode],
        TRUE,
        TRUE
      )
    )
    
  3. In the checking_form table, convert the Last giving date normal column to a virtual column, with this App formula expression:

    MAX(
      SELECT(
        bred_distribution[Next giving date],
        ([_THISROW].[Barcode] = [Barcode])
      )
    )
    
  4. In the checking_form table, convert the Result normal column to a virtual column, with this App formula expression:

    IF(
      ([Date] < [Last giving date]),
      "Do not Deserve",
      "Deserve"
    )
    

See also:










View solution in original post

13 REPLIES 13
Top Labels in this Space