QuickView Set Samples
This topic presents code snippets and samples of Spectre QuickView Set scripts.
quickview-set { // Make a QuickViewSet on a specific cPlan like this: cplan "southern.cplan" // Add a Dimension QuickView like this: dimension-quickview "Posting Period" { dimension "Posting Period" }
// And a List QuickView like this: list-quickview "label" { values "one" "two" "three" } }
NOTES:
- Spectre QuickViews are defined for a single cPlan.
- Dimension QuickViews are dependent in the order specified in the script.
- List QuickViews are independent.
- Values in a set can be sorted in the Build script.
- In DivePort, Spectre QuickViews work with Spectre Dives and markers that use cPlans.
-
In DivePort, the cPlan used by the QuickView Set should have the same named groups as the cPlans used elsewhere on the page.
This QuickView Set specifies each dimension in the cPlan as a potential QuickView.
quickview-set { cplan "/common/basic.cplan" dimension-quickview "Color" dimension-quickview "Direction" { default-values "East" "West" } dimension-quickview "Mood" dimension-quickview "Taste" all-values=false }
This QuickView Set indicates that each option is dependent on the others, but in no particular order.
quickview-set dependency="circular" { cplan "/common/basic.cplan" dimension-quickview "Color" dimension-quickview "Direction" { default-values "East" "West" } dimension-quickview "Mood" dimension-quickview "Taste"
}
This QuickView Set illustrates four ways to set the default value.
quickview-set { cplan "/common/basic.cplan" dimension-quickview "Color" { default-values "Red" } dimension-quickview "Direction" { default-values "East" "West" } dimension-quickview "Mood" { // "all values" is the implied default } dimension-quickview "Taste" all-values=false { // first value is the implied default } }
Consider a QuickView set with a date QuickView that has the reverse sort option, as follows:
dimension-quickview "Current Date" single-selection=true all-values=false { dimension "Invoice Date" sort { column "Invoice Date" reverse=true } }
When used in DivePort, this QuickView is sorted in reverse date order, such that the most recent date is listed first. Since all-values=false is in use, the Current Date QuickView defaults to the first value in the (reversed) list, that is, the most recent date.
This example defines and populates two list QuickViews.
quickview-set { list-quickview "Percentile" { values "5" "10" "20" "50" } list-quickview "Color" all-values=true { values "Red" "Green" "Blue" } }
This examples shows how to define a named group and specify its values. The first group has explicit values; the second depends on the data.
quickview-set { cplan "/common/basic.cplan" { dimension "Direction" { group "Northeast" "North" "East" } dimension "Mood" { group "Ends with y" `rsubstr(value("Mood"), 1, 1) = "y"` } } dimension-quickview "Color" dimension-quickview "Direction" { default-values "Northeast" } dimension-quickview "Mood" dimension-quickview "Taste" }
This anchor.qvset specifies a dimension QuickView on the date column. It can be used with the following cPlan and Dive files.
quickview-set { cplan { cbase-input "/common/demo_drl.cbase" } dimension-quickview "Date" label="Anchor" all-values=false }
cplan { // Parameterized: connects with anchor.qvset so the user can choose the anchor. take-parameter "Date" default="2016/06/30" cbase-input "/common/demo_drl.cbase" calc "Order Count" `dimcount("Order Num")` time-series { date "Date" // "Date" parameter is a string - turn it into a date to produce the anchor anchor `date(param("Date"))` summary "Units" summary "Cost" summary "Revenue" summary "Order Count" ranges { year-to-date } } }
dive { // Parameterized: connects with anchor.qvset so the user can choose the anchor.
take-parameter "Date" default="2016/06/30" cplan "time-series-parameterized.cplan" {
pass-parameter "Date" } window { dimension "Sales Region" column "Order Count YTD" column "Units YTD" column "Revenue YTD" } }
If you are trying to limit data presented on a DivePort page, you can define a filter on the cPlan when you specify the QuickView Set. For example:
quickview-set { cplan "all-data.cplan" { filter `value("Payor") = "A" and value("Specialty") = "B"` } dimension-quickview "Payor" dimension-quickview "Specialty" ... }
The filter in the cPlan defined within the set ensures that the QuickViews only include data for Payor "A" and Specialty "B".
Sometimes the order of the values in a QuickView are best sorted before presented to the end-user. For something like Week Day, you can use the sort-by attribute in a cBase build to get the desired result. This has the advantage of sorting that dimension correctly in places other than the qvset.
For example, if the Week Day and Week Day Sort columns are in the input, then include in your build script:
column "Week Day Sort" type="string"
column "Week Day" type="string" sort-by="Week Day Sort"
On the other hand, you can specify a sort on one column when you define the QuickView Set. For example:
quickview-set { cplan "sales.cplan" dimension-quickview "Order Date" { sort { column "Order Date" reverse=true } } }
This example includes a list-quickivew to be used with parameters.
quickview-set { cplan "/cplans/training/metric_timeseries.cplan" dimension-quickview "Product Name"
list-quickview "Metric" single-selection=true all-values=false { default-values "Cases" values "Cases" "Cost" "9 Liter Cases" "BATF Cases" "Discount" "Net Sales" } }
This example includes some nice-to-have QuickViews for the end-users.
quickview-set { cplan "patient_client_groups.cplan" dimension-quickview "Client" all-values=false single-selection=true { dimension "Client Group" } list-quickview "Limit Rows To" all-values=false { values "10" "25" "50" "100" "250" "1000" "5000" "10000" "100000000" } list-quickview "Not Seen in 18+ Months" all-values=true { values "True" "False" } }
This QuickView uses a year period that is defined in the cPlan.
quickview-set { cplan { cbase-input "/data/demo_drs/demo_drs.cbase" dimension "Year" `period("standard", "year", value("Order Date"))` } dimension-quickview "Year" }
See also: