Parameter Examples
Spectre parameters can be used in any quoted string with $(parameter_name) or in any Spectre expression with the function param("parameter_name").
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
dive {
take-parameter "Selected Dimension" ...
cplan ...
window {
dimension "$(Selected Dimension)"
...
}
}
build {
take-parameter "year_0" default="2016"
text-input "/build/data/$(year_0)*.dat" {
limit-similar-values-warnings 0
column "Account ID" type="string"
column "Charge Code" type="string"
...
}
output "/temp/test.cbase"
}
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
cplan {
take-parameter "Column1"
...
input "/common/basic.cbase"
...
calc "Column1" `calc(param("Column1"))`
...
}
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
The following code snippet shows how a cPlan can use a parameter to dynamically set time series columns.
cplan {
take-parameter "my_anchor"
...
time-series {
date "invc_date"
anchor `date(param("my_anchor"))`
...
}
}
The time series columns are set at run time when the parameter is supplied to the cPlan. This could be when a Dive file names the cPlan, or the Dive is used on a DivePort page with a Spectre QuickView Set in operation in a QuickView Portlet.
Alternatively, a cPlan can read calcs or parameter data from a text file.
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
You can use a simple text file with one value to pass externally determined anchor data to a cPlan. For example, the nightly ETL process could create a file today.txt with a date entry:
Process Date |
---|
12/04/2018 |
Assuming the specified today.txt file, the single column can be referenced as a parameter and used to define a calc, as shown here:
cplan {
. . .
for-file "today.txt" "Process Date" {
calc "run_anchor" `date(param("Process Date"))`
}
time-series {
. . .
anchor `calc("run_anchor")`
. . .
}
}
The for-file token iterates over rows of text in a file. This example has only one row, but there can be several rows. The cPlan can read each row and set different calculations based on the contents.
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
A cPlan can take and use parameters like this, where X is a summary column:
cplan { take-parameter "X" ... input "test.cbase"
... calc "Xtimes2" `calc(param("X")) * 2` }
A Dive can also take parameters and pass them into a cPlan like this:
dive { take-parameter "X" default="Weight" ... cplan "test.cplan" { pass-parameter "X" }
..... window { dimension "Color" column "Xtimes2" column "Value" column "Weight" } }
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
In the following example, the column Color is filtered on the values that are passed in or by the default values of Red and Blue. Therefore, the data set is reduced in size when presented with this cPlan.
cplan {
take-parameter "FilterValues" selection=true {
default "Red" "Blue"
}
input "/common/basic.cbase"
filter `param_match("FilterValues", "Color")`
}
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
This example accepts several parameter values to use as filters on the cBase data that is used in the cPlan.
cplan {
take-parameter "Location" selection=true {
default-all-values
}
take-parameter "Rendering Provider" selection=true {
default-all-values
}
take-parameter "Denial Classification" selection=true {
default-all-values
}
take-parameter "Denial Category" selection=true {
default-all-values
}
input "/cbases/denial_rates_canister.cbase" name="subset_denial_counts" {
filter `param_match("Location")`
filter `param_match("Rendering Provider")`
filter `param_match("Denial Classification")`
filter `param_match("Denial Category")`
rename "Denial Count" "Filtered Denials"
rename "Avg CPT Count" "Bad CPTs"
}
input "/cbases/denial_rates_canister.cbase" name="subset_cpt_counts" {
filter `param_match("Location")`
filter `param_match("Rendering Provider")`
rename "Denial Count" "Bad Denials"
rename "Avg CPT Count" "Filtered CPTs"
}
input "/cbases/denial_rates_canister.cbase" name="full_data" {
rename "Denial Count" "All Denials"
rename "Avg CPT Count" "All CPTs"
}
calc "Denial Rate Filtered" `calc("Filtered Denials")*100/calc("Filtered CPTs")`
calc "Denial Rate All" `calc("All Denials")*100/calc("All CPTs")`
}
Note that the full syntax for parameter_match is parameter_match(<parameter_name>, <column name>). If <column name> is omitted, it is considered to be the same as the <parameter name>.
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
This example includes parameters to help select groups of transaction files.
build {
take-parameter "year_0" default="2016"
take-parameter "year_1" default="2015"
text-input "/DIdata/TRANSACTIONS/*-$(year_0)*.dat" "/DIdata/TRANSACTIONS/*-$(year_1)*.dat" {
limit-similar-values-warnings 0
column "TX_ID" type="string"
column "ACCOUNT_ID" type="string" required-dimension="TX_ID"
column "PROC_ID" type="string" required-dimension="TX_ID"
column "SERVICE_AREA_ID" type="string" required-dimension="TX_ID"
rename "ACCOUNT_ID" "Guarantor Account ID"
rename "PROC_ID" "Procedure ID"
rename "SERVICE_AREA_ID" "Service Area ID"
rename "TX_ID" "Transaction ID"
}
output "/cbases/TEST_TRANS.cbase"
}
![Closed](../Skins/Default/Stylesheets/Images/transparent.gif)
This example includes a parameter to help select the appropriate SQL query file for the ODBC data extraction. Note also the use of a saved connect file to access the DSN.
build {
take-parameter "extract-type" {
default "initial"
}
odbc-input query-path="/data/queries/$(extract_type)_accounts.sql" {
connect-file "/data_sources/shared_connections/DB1-connect.cfile"
column-override "admit-source-code" type="string"
column-override "admit-type-code" type="string"
column-override "case-manager-id" type="string"
column-override "encounter ID" type="string"
}
output "/data/accounts/accounts.cbase"
}