Complex criteria for Select
Hi,
I am working on a project which requires a dynamic choice field to be populated by the results of a select based on one or more of four criteria. The criteria are selected at the top of a dashboard. I can set the code to populate the choice field for anyone of the criteria, but to cater for the any one or more scenarios, 12 I think, would result in a humungous block of if..then..else.
I had hoped to solve this by running a series of select statements on the result of the previous one. However, unlike SQL, Ninox doesn't seem to be able to make a temporary table from the results of a select, only an array. Nor does it seem possible to run a select on an array.
Any suggestions on how to go about this?
On this screen shot the criteria are the 4 fields at the top and the choice field is at the bottom.
20 replies
-
Hi, try the following:
-
As you have some "Show All" options you may need to build your where clause as a text string and evaluate it, such as
Regards John
-
Do your records in Film also have reference fields to Status, Camera, Film Stock, and Format? That will make filtering/search easier.
said:
I had hoped to solve this by running a series of select statements on the result of the previous one.What Ninox can do is filter arrays. So you could do something like:
This is not a solution for you question, but just information.
-
Thanks Fred. Yes, there are reference fields and filter is interesting, it is similar to the solution I was seeking. Yet again "this", is there a crib sheet for when to use it?
-
The simplest solution I can think of is the following:
-
Thanks for your contributions chaps. Cracked it!
let t := this;
let myRecordSet := rsort((select Film) order by 'Index Number');
if t.'Filter by Status' < 7 then
let myfilter := myRecordSet[Status = number(t.'Filter by Status')];
myRecordSet := myfilter
end;
if t.'Filter by Format' < 4 then
let myfilter := myRecordSet['Film Format' = number(t.'Filter by Format')];
myRecordSet := myfilter
end;
if 'Filter by Camera' != null then
let myfilter := myRecordSet[Camera = number(t.'Filter by Camera')];
myRecordSet := myfilter
end;
if 'Filter by Film Stock' != null then
let myfilter := myRecordSet['Film Loaded' = number(t.'Filter by Film Stock')];
myRecordSet := myfilter
end;
myRecordSet
Content aside
- Status Answered
- 7 mths agoWed, August 21, 2024 at 7:40 AM UTCLast active
- 20Replies
- 150Views
-
6
Following