I am having trouble with the IsEmpty() function when performing a LookUp() on a collection. I am trying to determine if a user has certain privileges (none, user, etc) based on a collection. Due to the complexities of the data in the collection, I assume a privilege of "none" and then query the collection for conditions that would establish the user as a "user".
In each case, my code uses the following format:
Set(varUserRole, "None");
ClearCollect(collectUser, Filter(<table name>, EMAIL = <email address>);
If(
IsEmpty(LookUp(collectUser,<conditions for a user>),
Set(varUserRole, "None"),
Set(varUserRole, "User")
);
For a user with no special privileges, collectUser would be empty, so the LookUp would not find any records and would also be empty. However, the IsEmpty() function apparently returns false as varUserRole always comes back as "User".
Solved! Go to Solution.
@Drrickryp is correct, you use IsBlank because when LookUp is blank it returns blank, from the MS docs
Filter and Search return a table that contains the same columns as the original table and the records that match the criteria. LookUp returns only the first record found, after applying a formula to reduce the record to a single value. If no records are found, Filter and Search return an empty table, and LookUp returns blank.
@Drrickryp , I assume you meant to suggest IsBlank(), which seems to work. However, that doesn't make sense to me. It is my understanding that LookUp() returns a record not a value, IsBlank() looks for a null value, and IsEmpty() looks for a null record. So how can IsBlank() return true when evaluating a record returned by LookUp()?
@Drrickryp is correct, you use IsBlank because when LookUp is blank it returns blank, from the MS docs
Filter and Search return a table that contains the same columns as the original table and the records that match the criteria. LookUp returns only the first record found, after applying a formula to reduce the record to a single value. If no records are found, Filter and Search return an empty table, and LookUp returns blank.
User | Count |
---|---|
258 | |
111 | |
95 | |
48 | |
41 |