Bug in virtual column, simultaneously right and wrong data in the same view

I have a table of invoices that contain a "Date Issued" (date) column and a price "Amount" (price) column.

I also have a table of approval rules that define a range of price amounts are automatically approved or denied, as well as a range of dates that are automatically approved or denied (for example, approve everything before a certain date to help with entering past data into the system). Each rule has a "Priority" (number) column.

The invoices table has a virtual column called "Applicable Approval Rules" (List of ref's to approval rules) that aggregates all approval rules that the row meets the range criterias of.

 

Show More
ORDERBY(FILTER("Approval Rules",
 AND(
  OR(
   ISBLANK([Amount Range Type]),
   [Amount Range Type] = "",
   SWITCH([Amount Range Type],
    "< X", [_THISROW].[Amount] < [Amount X],
    "<= X", [_THISROW].[Amount] <= [Amount X],
    "> X", [_THISROW].[Amount] > [Amount X],
    ">= X", [_THISROW].[Amount] >= [Amount X],
    "between X and Y (lower inclusive)",
    AND([_THISROW].[Amount] >= [Amount X], [_THISROW].[Amount] < [Amount Y]),
    "between X and Y (upper inclusive)",
    AND([_THISROW].[Amount] > [Amount X], [_THISROW].[Amount] <= [Amount Y]),
    "between X and Y (inclusive)",
    AND([_THISROW].[Amount] >= [Amount X], [_THISROW].[Amount] <= [Amount Y]),
    "between X and Y (not inclusive)",
    AND([_THISROW].[Amount] > [Amount X], [_THISROW].[Amount] < [Amount Y]),
    false
   )
  ),
  OR(
   ISBLANK([Date Range Type]),
   [Date Range Type] = "",
   SWITCH([Date Range Type],
    "before date", [_THISROW].[Date Issued] < [Date 1],
    "before date (inclusive)", [_THISROW].[Date Issued] <= [Date 1],
    "after date", [_THISROW].[Date Issued] > [Date 1],
    "after date (inclusive)", [_THISROW].[Date Issued] >= [Date 1],
    "between dates (earlier inclusive)",
    AND([_THISROW].[Date Issued] >= [Date 1], [_THISROW].[Date Issued] < [Date 2]),
    "between dates (later inclusive)",
    AND([_THISROW].[Date Issued] > [Date 1], [_THISROW].[Date Issued] <= [Date 2]),
    "between dates (inclusive)",
    AND([_THISROW].[Date Issued] >= [Date 1], [_THISROW].[Date Issued] <= [Date 2]),
    "between dates (not inclusive)",
    AND([_THISROW].[Date Issued] > [Date 1], [_THISROW].[Date Issued] < [Date 2]),
    false
   )
  )
 )
), "Priority", false)

 

 

But I'm getting a bug in the view and subsequent virtual column calculations. The view showing the List of "Applicable Approval Rules" says there is one item in the list (incorrectly), but shows two items (correctly).

appsheet-error-1.PNG

But other virtual columns referencing this one only see the one item reference (or none, or the wrong data altogether). For example, in the image above the virtual column "Applicable Approvals" (List of enum, either "Approve" or "Deny") is missing the "Deny" result after "Approve". The App Formula for it is:

 

[Applicable Approval Rules][Action Type]

 

On another invoice (pictured below), notice how the "Applicable Approval Rules" column correctly has the "Deny" rule applying, but the "Applicable Approvals" column incorrectly reports a value of "Approve" (the [Action Type] should be "Deny").

appsheet-error-2.PNG

Running the "Test" routine from the App Formula window shows wrong data is filling the virtual column "Applicable Approval Rules". In the picture below, the value 8926004a is the approval rule that has the action "Approve", but for whatever reason the approval rule that has the action "Deny" is absent in the first row's results, and replaced in the second row's results with the wrong one (should be a "Deny" reference, not the "Approve" one (8926004a)).

appsheet-error-3.PNG

If those values are really in the virtual column results, how is it that the List view of the column is able to show the correct data (though it says the wrong count of data it's showing)?

I don't know if I was narrowing the problem, but I noticed that SWITCH and IF statements were losing the context of [_THISROW] the the second, third, and other params if [_THISROW] was not used in the first param of the SWITCH and IF statements. The context was fixed if I included the [_THISROW] reference in the first param.

My virtual column relies on a Filter that uses two Switch statements to generate the list, and the problem persists if I switch out Filter with Select and Switch with If's.

0 0 61
0 REPLIES 0
Top Labels in this Space