Action button display despite a behavior rule returning a negative value

Hi.

Am I pushing the limit of behavior rules by running a query on children records to determine if an action button should be displayed?

In the example below the action button GA1 Run Start is displayed even if the behavior query returns a negative value.

Solved Solved
0 15 568
1 ACCEPTED SOLUTION

It sounds like @Steve got you fixed up. For what its worth, when I am checking for existence of rows I typically use COUNT(). Depending on what I need/want, I use COUNT() = 0 or COUNT() > 0 .

ISBLANK() just never feels right to me when its a list of values being returned. For example what happens if only one item is returned and it is a blank?

EDITED: so I would implement it very close to what @Steve did but using COUNT() like this:

COUNT(
  FILTER(
    "Log bdt",
    AND(
        [Bon de travail ID] = [_THISROW].[Bon de travail ID],
        USEREMAIL() = [Usager],
        ISNOTBLANK([Date debut]),
        ISBLANK([Date fin])
    )
  )
) = 0

View solution in original post

15 REPLIES 15

No. But I am wondering about the usage of ISBLANK(INDEX()). Are you trying to determine if a record exists or not?

Also, you can simplify the AND(AND()) into a single AND

Hi @WillowMobileSystems.

Yes! It sounds like you have something in mind to propose.

It sounds like @Steve got you fixed up. For what its worth, when I am checking for existence of rows I typically use COUNT(). Depending on what I need/want, I use COUNT() = 0 or COUNT() > 0 .

ISBLANK() just never feels right to me when its a list of values being returned. For example what happens if only one item is returned and it is a blank?

EDITED: so I would implement it very close to what @Steve did but using COUNT() like this:

COUNT(
  FILTER(
    "Log bdt",
    AND(
        [Bon de travail ID] = [_THISROW].[Bon de travail ID],
        USEREMAIL() = [Usager],
        ISNOTBLANK([Date debut]),
        ISBLANK([Date fin])
    )
  )
) = 0

I think thereโ€™s no difference in AppSheet between a list with one blank item and a list with no items. If you consider how each of those would be stored in a spreadsheet cell, both would be an empty cell. I havenโ€™t confirmed this, though. Certainly, though, your approach avoids the question altogether, and is perfectly valid.

A quick test to confirm!

A List with NO items is considered blank
2X_3_328ef0faaf42c4563d8eef1ccd8d95e4cc4fe374.png

A list with 1 blank item is considered NOT blank
2X_a_a67060e4cd661fdb2ee9cbdc6fa78f39203331be.png

Of course, FILTER() will never return a blank item, since thereโ€™s no such thing as a row without a key.

Good Point! Thatโ€™s what happens when you donโ€™t test exactly whatโ€™s being used!!

Hi @WillowMobileSystems.

Thanks for your query with COUNT! It makes a lot of sense. I like it.

Steve
Platinum 4
Platinum 4

Your expression, reformatted for my clarity:

ISBLANK(
  INDEX(
    FILTER(
      "Log bdt",
      AND(
        AND(
          ([Bon de travail ID] = [_THISROW].[Bon de travail ID]),
          ([Usager] = USEREMAIL()),
          ([Date debut] <> "")
        ),
        ([Date fin] = "")
      )
    ),
    1
  )
)

Then with some improvements:

ISBLANK(
  FILTER(
    "Log bdt",
    AND(
      ([Bon de travail ID] = [_THISROW].[Bon de travail ID]),
      (USEREMAIL() = [Usager]),
      ISNOTBLANK([Date debut]),
      ISBLANK([Date fin])
    )
  )
)

Does that fix it?

Also, expanding the dropdown highlighted in green below might shed some light:

2X_0_0c5e7be0d0cbdb6ea7f93d4df5e76fd28fffbd2e.png

Hi Steve.

Thanks for taking the time to teach me some SQL and providing my with a solution!
Your query end up with the same negative value as mine but the action button react positively to yours. I know my SQL is just enough to craft something far from perfection or good performance. I am puzzled on what make yours to work.

As requested the information you asked. It looks like the execution steps/plan of the SQL query.

my query results:



Your query results:
2X_b_b9e2600b66a357160245da1dd51b9c5776d68ab3.png 2X_e_eb652f12d786e81ec44cb24f238506740dc33e55.png

What is bothering me is that from your images of the test results, it seems to imply that the SELECT() (created from the FILTER() function) is returning 4 rows?

As far as I can tell, it should be returning only the one row that matches [Bon de travail ID] and only if the other details match the criteria. So you only get a single row or no rows. But then again, I am making assumptions. I havenโ€™t seen your data nor how you have defined the columns.

Additionally, when a list of values are returned by any LIST type function, there is never a guarantee of order. So when applying the INDEX() function you cannot assume which row is going to be returned.

If your intention is for the FILTER() function to return a single row or none. Then I would temporarily focus on just this FILTER() expression. Create a VIRTUAL COLUMN and investigate it by itself until you can figure out why its returning more than one ID. This seems critical for the Action to behave correctly.

Just a point of clarity: the expressions AppSheet uses are not SQL. If you say โ€œSQLโ€, that means something particular to many people. We call what AppSheet uses โ€œexpressionsโ€. I offer this clarification to help you avoid confusion in the future.

As to why my expression works where yours doesnโ€™tโ€ฆ I suspect itโ€™s because of a quirk in the way AppSheet handles the is-equal operator (=) and is-not-equal operator (<>). For some reason, if the left-side operand to = or <> is blank, the result will be TRUE regardless of the right-side operator. For instance, consider this from your expression:

([Usager] = USEREMAIL())

If the rowโ€™s Usager column value is blank, that expression is TRUE, even if USEREMAIL() gives a non-blank value!

But this is likely the actual problem:

([Date debut] <> "")

If the Date debut column value is blank, the expression is TRUE, even though your intention is specifically to test that it is not blank!

To work around this quirk, the left-side value should be non-blank. USEREMAIL() will always give a value, so I swapped it around:

(USEREMAIL() = [Usager])

To test whether a value is blank or not, rather than comparing to "", I used the fuctions specifically provided for this purpose:

ISNOTBLANK([Date debut])

and:

ISBLANK([Date fin])

Hi @Steve.

Thanks for this explanation!

@paullynun @Steve

I am still concerned with your test results returning more than one row. It looked like in your images for both yours and Steveโ€™s version of the FILTER() expression, that 4 rows are being returned. Based on my understanding, that should not be happening! I would recommend investigating into it a bit deeper.

Hi @WillowMobileSystems.

I appreciate your concerns. For now it is a data issue (something that should not happened as far as I can see).

I invite you on this topic How to find a lost child? ๐Ÿ™‚ to better understand the big picture and share your valuable knowledge. This could resolve your concerns.

Top Labels in this Space