Easy Tricks for Better Models

Revision as of 17:07, 3 November 2022 by BFilstrup (talk | contribs)


Choice Dropdowns
One of the biggest missed opportunities we see at Lumina when reviewing customer & client models is the infrequent use of the Choice() and MultiChoice() functions. Making use of these will not only make your model more clear from a client perspective, but will also make your model more flexible should something like an index change in the future.

To demonstrate this you can view the video below or read on:
VIDEO EMBED HERE

Choices as Labels
When trying to make our model more flexible we should think of using Choice() as a "label". A label, as we describe it, is a node that uses Choice() to reference a value from an index. The value of using labels should become more apparent from the following example.


Scenario
I've created a model that references values in my index called "Fruits". However, I notice midway through development that I've actually made a typo in my index:
Choice Tips 1.jpg

If I fix the typo in my index then everywhere else I reference it in the model will break. This headache could've been easily avoided by making use of labels. Here's how that structure might look:
Choice Tips 2.jpg

Labels take care of issues like typos because all references point to a single label node that grabs its value based on the position in an index.

To use labels, find the parts of the model that reference an element from the index and then instead of typing something like:
[Fruits = 'Apples']

you would type:
[Fruits = Apples_Label]


Other Benefits from Labels
Another reason to use labels is to help track where specific elements of an index are being used. If I needed to find every place 'Apples' was used in my model, I could look at the object window for Apples_Label and view the list of Outputs:
Choice Tips 3.jpg

But what about tables?
Choice() can also be used in tables. Simply type the definition inside a table cell and Analytica will handle the rest:
Choice Tips 4.jpg Choice Tips 5.jpg

What about MultiChoice()?
Although not really applicable for labels MultiChoice() can also be used in tables and can be an effective solution when you need to create a table of references.


If you'd like to play with the model used in this page, you can download it here:
MODEL DOWNLOAD HERE

Comments


You are not allowed to post comments.