Pseudo Functions
Spectre pseudo functions are not proper functions—they do not result in any run time calculations. Instead, these functions substitute expressions or parts of expressions into other expressions.
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
calc(calc_name : string) : expression
For example:
`calc("Revenue")` substitutes the expression named Revenue, defined earlier, into the calculation
calc "Accounts with Late Charges" `filter(dimcount("Account ID"), sum(value("Late Charge Amount")) > 0)` when used in a cPlan, calculates the number of accounts with late charges
calc "Calendar_sort" ``` switch(calc("Month Name"), "January", 1, "February", 2, "March", 3, "April", 4, "May", 5, "June", 6, "July", 7, "August", 8, "September", 9, "October", 10, "November", 11, 12)```
calc "Current Date" `date(file_contents("current-date.txt"))` when used in a cPlan, sets the Current Date based on what is in the text file
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
eval(expression_string : string) : expression
For example:
`eval("1 + 1")` returns 2
`eval("length(\\"test\\")")` returns 4
add "First" `eval("value(\\"column1\\")")` adds a column to the cBase named First with the same data as column1
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
param(parameter_name : string) : expression
For example:
`param("Year")` returns the value set for the Year parameter
filter ```value("Payment Status") = "Closed" and value("Payments") > 0 and value("Service Month") >= same_period(value("Service Month"), param("Start Month"),"YYYY-MM") and value("Service Month") <= same_period(value("Service Month"), param("End Month"),"YYYY-MM") ```
—when this filter is part of a cPlan with parameters, the start month and end month are evaluated before the rest of the expression
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
param_contains(parameter_name : string, value : string) : expression
For example:
`param_contains("State", "Ohio")` determines if the State parameter value is Ohio
calc "Total" `if(param_contains("Summary","SumA"),sum(value("SumA")),sum(value("SumB")))` when used in a cPlan, calculates the total using data from SumA or SumB, depending on the value set for the parameter named Summary
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
param_match(parameter_name : string, column_name : string) : expression
For example:
`param_match("State")` determines if the State parameter value matches the value in the State column
calc "Brand Cases" `calc("Cases")` filter=`param_match("user-select-brand", "Brand")` label="First Selection" calculates cases for the user selected brand
calc "XXX Cases" `calc("Cases")` filter=`param_match("user-select-dimension-value", param("select-dimension"))` label="First Selection" calculates cases labeled "First Selection" based on the value of the parameters: user-select-dimension-value and select-dimension
See also: Alphabetized Functions for Spectre.