Introduction
Enriching data is at the heart of analysis modelling from adding additional data and extrapolating information to performing complex calculations and deduplication, PhixFlow covers it all. In this page we will highlight some of the key areas of enrichment, provide examples, and list the links to additional useful enrichment resources.
PhixScript Functions
PhixScript is the language of PhixFlow and it can be used anywhere that supports expressions, such as attributes on a table and in filters. There are over 115 functions available and these are listed in the Functions section along with supporting information.
Where a PhixScript is more than a single function, it must be wrapped in a do()
function. do()
can also be used within functions where you need to carryout multiple functions such as in if
or switch
.
Single Function PhixScript
These are useful in attribute expressions and filter alike.
// If ExamResult is greater than 95 then return "Distinction" else return "Pass" if( in.ExamResult > 95, "Distinction", "Pass")
Multiple Function PhixScript
PhixScripts containing multiple functions must be wrapped in a do(). For more information see do().
The value returned from the PhixScript is the final value output, therefore it is useful to add the desired output to the end of the script.
Note that variables declared in an attribute expression (variables are declared with a $ symbol with the data type being implied) will be accessible to subsequent attributes within the same table by using the $variable name.
do( // calculate the miles per gallon. $mpg = in.distance / in.gallonsUsed, // if $mpg is over 65 set efficiency to Highly Efficient if( $mpg > 65, $efficiency = "Highly Efficient", // ELSE, set $efficiency to be null $efficiency = _NULL ), // Set the value returned by the PhixScript $efficiency )
lookup Information
Lookups can be performed using three different techniques, the method selected depends on your requirements.
Lookup Function with Filtering
Scenario
Allows you to lookup information from a separate table and pass filtering information dynamically to return only selected records.
Example
You need to retrieve all invoices for a specific date range that have not been sent.
Solution
Lookup Function with with Cached lookup
Scenario
This is a highly efficient method for performing a lookup against a small set of records. This kind of lookup will automatically cache a set amount of records, 3000 by default, in memory allowing for faster lookups.
Example
You have a product code on an invoice and want to return the name of the product to display. There are a finite amount of products.
Solution
lookup with with Cache Function
merges
matching