Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Pick lists in calculations
- This topic has 5 replies, 3 voices, and was last updated 7 years ago by Chris Knight.
-
AuthorPosts
-
December 1, 2017 at 10:25 PM #26395
Chris KnightParticipantHey Brendan.
How are pick lists stored? Are they a list object?
I created a text field called “pick list” and attached it to a pick list I made that is a multiple value popover with every day of the week in it.
I created a calculation field called “pick text” that has only the field “pick list” in it and is set to return as text.
It won’t update the calculation until I leave the form and come back to it or click save. But, it gets me thinking that it would be cool if I could use this like a list.
I would need another function (insert Brendan’s exasperation with me here ;-).
IFLIST(field, logical operator separated list of strings, case A, case B). Field is the multi-selection popover or combo box. The list is the fields logical rules to create a search in the list, case A is if the rule matches and case B is if it doesn’t.So, if I have a picklist called genres. It has typical movie genres such as SciFi, Drama, Romance, Comedy, Mystery, Adventure, Horror, Thriller, Psychological, etc I could test in a calculation if one or more genres had been selected. Let’s say I have a field call, “genre” that is connected to the genre pick list and another field call “rejected” that is a calculated field with
IFLIST([genre],!("Thriller"~"Psychlogical"~"Horror"~("Romance"&"Drama")),"Rejected","")
if the current record has a genre either thriller, psychological, or horror it gets rejected if it has both romance and drama it also gets rejected. If there are no reasons to reject it then the second case puts an empty string in the field.Kind of a silly use case because one could just to the reject as they are making the record. How about I use other tools though to create import data from one of the movie databases to create the records automagically? Then this kind of calculation isn’t so silly anymore but instead a useful way to do some data mining. The real power of it comes when a new “list” field type come to Tap Forms (hint, hint) and testing if elements are in, or are not in, the list.
I’m just thinking out loud because I’ve been thinking about how I might be able to coax TapForms into doing more interesting aggregate reporting and was doing a survey of the field types and thinking how they could be leveraged and then started wondering about how some of the fields’ data was stored internally.
~Chris
December 1, 2017 at 11:22 PM #26396
BrendanKeymasterHi Chris,
Pick Lists are stored as an array of JSON dictionaries of keys and values.
"values": [{ "value": "Australian Dollars", "valueColour": "" }, { "value": "Canadian Dollars", "valueColour": "" }, { "value": "Euros", "valueColour": "" }, { "value": "Pounds Sterling", "valueColour": "" }, { "value": "Yen", "valueColour": "" }, { "value": "US Dollars", "valueColour": "" }]
It should update the Calculation field results right after you dismiss the Pick List popover view. I just tested on a multi-select Pick List with a Calculation field that had only that field the Pick List was assigned to it. It evaluated the formula as soon as I selected values and closed the popover.
I’m not sure why it didn’t for you.
If you can send me your template I can look at it to see what’s different about what you’re doing.
What would be nice instead of me making a bazillion functions to do all kinds of things, would be to incorporate a programming language so you could write your own algorithms and output whatever results into a field.
December 2, 2017 at 3:25 AM #26397
Chris KnightParticipantHi Brendan,
Thanks!
There is not much to the form at all. I find that all kinds of things don’t update immediately and I have to save and then click edit again, leave the form, select multi-column mode or something like that to see the results of some calculations. It isn’t all of them. Sometimes it happens when I change a calculation field also. The form is attached.
Yeah, a programming language inside would be great. I could have a lot of fun if it wasn’t a bar to use and at least if it were a reasonably good one that took care of a lot the stuff of problems behind the scenes like allocation and deallocation and general garbage collection. I can vote for Python again but I did read a comparison of the two the other day and learned Swift has a Switch statement and it always annoyed me Python doesn’t so that is a point in Swift’s favor. I’ve no idea though if Swift can be embedded like Python can into an app. Hmm. It would defiantly be great if you could do this but I imagine that is going to be a quite a project. Might be easier to write a bazillion functions for me :-)
Attachments:
You must be logged in to view attached files.December 2, 2017 at 5:03 AM #26400
Jose MonteiroParticipantIf a programming language then one more vote for Python.
Jose
December 2, 2017 at 12:09 PM #26401
BrendanKeymasterI don’t see any issues with your template. When I select an item (or items) from the popover and close it, the Calculation field updates.
I’m not sure why it’s not updating right away for you. I thought it was maybe because I was using my latest development build right from Xcode, but then I launched build 1742 and it updated there too every time.
So I’m not sure what’s going on.
December 2, 2017 at 2:33 PM #26410
Chris KnightParticipantWell Hmm. I will start paying more attention to exactly when it happens and what I did just prior to it and start a log and post that after I have more info on it that might help you to see what is going on.
-
AuthorPosts
You must be logged in to reply to this topic.