Sometimes you need to use the same lookup multiple times in your dataset. This could have performance implications as it could lead to an unnecessary repeat of setup. In this scenario you might be able to use an alternative approach to the out of the box auto and manual lookup modes, involving the creation of an empty lookup property. This empty property holds the connection to your lookup dataset and is then used to populate the other properties of your dataset through calculations.
An example:
-
In your Positions dataset, you have multiple Location properties: Base Location, As Is Location, and To Be Location.
-
You have a Location Lookup dataset which is used to retrieve the Country from the Location.
-
All three of your Location properties use this Location Lookup dataset.
In this scenario you can use the approach mentioned. Use the following steps:
-
Create a Location Lookup property in your dataset. Ideally you name the key of this property the same as your Lookup dataset and its ID property. You can change the Display Name as you please. For more details see How do I add a lookup?
-
Connect this property to your Lookup dataset. If the naming convention aligns between the property key and the dataset you should use the Auto mode.
-
Disconnect the Lookup on your Base Location, As Is Location, and To Be Location properties. Add your possible Location values through the drop-down list option.
-
Use the following Gizmo template expression to retrieve additional properties from your lookup dataset as needed through calculations:
view.property("location").lookup(node.asIsLocation).country
In this you would retrieve the As Is Country. You can change the following components of the expression:
- location is the property key of your Location Lookup property
- node.asIsLocation is your lookup value with which to retrieve data from your lookup dataset
- country is the property from your lookup dataset you want to retrieve
Some notes and considerations:
-
While not mandatory, you should maintain your list of possible Location values at the property level as well as in your lookup dataset. While not mandatory, this will enable the users to still be able to select locations through the drop-down. It is one downside of this approach: maintaining the values in a list format for the property, instead of the values automatically being inherited through the lookup. This can cumbersome if your lookup updates frequently.
-
The Lookup property can and should remain empty at the node level. The property just needs to be part of the dataset.
-
In the expression you can also lookup variables when working in an on demand. A common use case of this is when you have a Rate Card value you are combining in your on demand expression that then feeds into the lookup dataset.
-
This approach also works when using a manual lookup mode. However, you will experience less performance benefits than with the auto mode.
Comments
0 comments
Please sign in to leave a comment.