I have an odd problem with a gallery. I have an If/then function to change the data source of a gallery. Both are the same source, one with, and one without a filter. The If function checks the value of a toggle. I'm doing this to avoid the delegation warning that occurs when I place the if/then function directly inside the the filter function. What's happening, is when both the true and false statements are provided, my CountRows(ThisItem.Attachments) function within the gallery returns no value. ThisItem.'Has Attachments' is functioning as normal. If I remove the false portion of the data source formula, it magically starts working. This is the only thing not working, and there is no error or warning.
Here is the result with both the true and false portions in the formula. (The If function is currently true). See arrow at the bottom.
And here is the exact same thing, but with the false portion omitted (The statement is still true, meaning the gallery contains the same items from above): See arrow at bottom.
Solved! Go to Solution.
In general it is bad practice to use If statements in your Items property. There ais only one condition that I know of where it is acceptable to use.
Not only are you seeing the issue you are, but you are also repetitively duplicating your formulas in the Items property.
Please consider changing your Formula to the following:
SortByColumns(
Filter('Receiving Log',
StartsWith(Title, txt_SearchContainers_1.Text),
!Toggle1.Value || Status.Value = "Staged" || Status.Value = "In Progress"
),
"ReceivingDateTime"
)
This is equivalent to your prior formula but excludes the If statement and duplication.
I hope this is helpful for you.
In general it is bad practice to use If statements in your Items property. There ais only one condition that I know of where it is acceptable to use.
Not only are you seeing the issue you are, but you are also repetitively duplicating your formulas in the Items property.
Please consider changing your Formula to the following:
SortByColumns(
Filter('Receiving Log',
StartsWith(Title, txt_SearchContainers_1.Text),
!Toggle1.Value || Status.Value = "Staged" || Status.Value = "In Progress"
),
"ReceivingDateTime"
)
This is equivalent to your prior formula but excludes the If statement and duplication.
I hope this is helpful for you.
Thank you for the enlightenment regarding If statements in the items property. How is this able to work properly? I thought the filter continues to evaluate through each of the OR || items? Regardless, thank you so much, it is working beautifully!
The primary motive in the Filter function is to return a true or false. Filter iterates through every row of your datasource (delegated if it can delegate, locally if not). During that iteration, it will evaluate the formula in the criteria. The formula evaluates to either true or false. If it is true, the current iterated row is included in the results table. If false, it is not.
So, the formula I provided just uses plain old Boolean logic to evaluate to either true or false.
If the Toggle is not on, then !Toggle1.Value will return true. Since it is OR'ed with all the other values, it doesn't make a difference what they return because true OR'ed with anything else will always be true.
With toggle turned on, !Toggle1.Value will be false. So, the rest of the formula is evaluated. If either of the other two conditions are true, then the result is true and the record included. If not, then the record is ignored.
Now I understand. Thank you so much! I think I've had delegation issues elsewhere in my app that you may have just solved with this 🙂
Excellent!
Yes...if you use IF statements in the Criteria that should evaluate to true or false, this often leads to delegation issues. Always thrive for straight Boolean logic.
User | Count |
---|---|
252 | |
126 | |
104 | |
50 | |
50 |