User Defined Fields (UDFs) are new (synthetic) fields that you can create directly in SuperCROSS based on existing fields and measures.
You can use UDFs to do things like:
- Compare two numeric fields.
Perform calculations across several numeric fields.
Range or band a continuous numeric field.
Copy data from a child fact table to a parent. For example, deriving household income based on individual income.
Determine if a parent object contains any children.
Calculate a time or data span.
Apply weights to a value set to be used in a subsequent calculation.
You can recode UDFs and in some instances use them to create other UDFs to build up complex results.
If you have created UDFs in SuperCROSS then you can add these to your SuperWEB2 server. The UDFs will appear in the field tree for use by SuperWEB2 users just like any other field in the dataset.
Add Defined Fields to SuperWEB2
To add UDFs to SuperWEB2:
- Follow the steps in the SuperCROSS documentation to create your UDFs.
Save your UDFs to a file in Textual Defined Field (.txt) format.
You must use the textual format, not the binary Defined Field (.fld) format.
Copy the .txt file to <tomcat_home>\webapps\webapi\WEB-INF\resources\udf\<dataset_id>\ (where <dataset_id> is the ID of the dataset that the UDF applies to; you will need to create this directory if it does not already exist).
For example, if you have created a UDF for Retail Banking (ID: bank) you would copy the file to <tomcat_home>\webapps\webapi\WEB-INF\resources\udf\bank\
Your UDFs will automatically be available to any user who accesses this dataset.
Time span UDF created in SuperCROSS:
The UDF as it appears in SuperWEB2:
Adding Multiple UDFs
If you want to add multiple UDFs to SuperWEB2, then you can either save these to individual .txt files or as a single .txt file with all the UDFs defined in it.
UDFs are exported with their dependencies, for example a Comparison UDF may have a dependency on another UDF such as a Math UDF. This means that when the UDF is exported, the file contains multiple UDFs.
To overcome duplication of UDFs in SuperWEB2, it is recommended that you do not export UDFs that are already part of a UDF, for example when you export the Comparison UDF, there is no need to export the Math UDF.
If by chance, you accidentally export duplicate UDFs, for example you exported both the Comparison and Math UDF, you should manually remove the Math UDF from the dataset's UDF directory to avoid duplication in SuperWEB2.
Ensure your UDFs have Unique Names
Take care to ensure that all your UDFs have unique names. If you add multiple UDFs with the same name, then users will be able to create tables but will not be able to save tables containing these UDFs.
If you create a UDF that is not valid for a particular dataset (for example because you have saved the UDF file to the wrong directory on the SuperWEB2 server) then this will be ignored. When SuperWEB2 encounters an invalid UDF in a .txt file, all UDFs defined in that .txt file will be ignored and will not be available in SuperWEB2.