If (PQL)
Evaluates a logical expression, returning the one result if true, or another if false.
- Returned Output: Variant
- Library: PQL \ Granular \ Logical
- Version: 2023.00.000
- Compatibility: Pyramid Query Language (PQL) data sources
Syntax
* Click on the function's arguments above for more details on the input values.
Comments
- Criteria: A logical check to evaluate. This argument can be a simple or complex logical statement made up of columns, values, other functions, and operators.
- TRUE: The result that will be returned if the criteria evaluates to true. The result argument can be a simple or complex statement made up of columns, other functions or values.
- FALSE: The result that will be returned if the criteria evaluates to false. The result argument can be a simple or complex statement made up of columns, other functions or values.
- For details on how to employ and use this function see the custom column overview.
Different Function types
- This function is similar to the PQL semantic and common functions of the same name. However, it operates on a column directly at the grain.
- It is also similar to the CASE and SWITCH functions.
- As a granular function, it is used in the base SQL query itself.
Example
This example checks if the values in the price column are 15% higher than the values in the cost column. If they are, it returns the word "profits," otherwise it returns the word "losses."
If( [transactions].[Price]>([transactions].[Cost]*1.15) , "profits" , "losses" )
You can see the effect from this example snippet in the if column #4, based on the Price and Cost columns in positions #2 and #3. (It effectively does the opposite of the not column at position #5.