Help:RiskDataLookup
Help:RiskDataLookup
The <riskdatalookup> tag fetches a row from a RiskData table and sets values for one or more variables used in a risk calculation defined by a RiskModel or RiskDisplay. It is used on main pages alongside <riskdisplay> and <dropdown> tags to "hard-code" values specific to the page’s context.
Syntax
Basic syntax:
<riskdatalookup table=riskdata_table_name row=row_value rowindex=N />
Usage
- Use the <riskdatalookup> tag on a main page alongside <riskdisplay> and <dropdown> tags to set fixed values for variables used in a risk calculation.
- Set the table attribute to the name of a RiskData table, either on the same page, on a /Data subpage, or specify the full name of the RiskData table (e.g. Driving/Data:injury_model ).
- The optional row or rowindex attribute specify which row to fetch. If neither is specified then the first row of data (rowindex zero) is selected.
Examples
The following examples use this riskdata table:
a | b | c | value |
---|---|---|---|
a1 |
b1 |
c1 |
1.0 |
a2 |
b2 |
c2 |
2.0 |
a3 |
b3 |
c3 |
3.0 |
Lookup a row by value
This will lookup the second row:
<riskdatalookup table=testlookup1 row=a2 />
... and set {a}=a2 {b}=b2 {c}=c2 {value}=2.0
Lookup a row by index
Use rowindex= to lookup a row by number:
<riskdatalookup table=testlookup1 rowindex=2 />
Rows are indexed starting at zero, so rowindex=2 will get the third row and set {a}=a3 {b}=b3 etc.
Dynamically fetching from different tables using RiskDisplay
Putting a RiskDataLookup inside a RiskDisplay element allows you to make the lookup dynamic, based on user input on the page. For example, if DataTable1, 2, and 3 all contain three rows, you let the user fetch any row from any of the three tables with two DropDowns:
<riskdata table="selecttable" columns="table"> DataTable1 DataTable2 DataTable3 </riskdata> <riskdata table=selectrow columns="row|rowindex"> 1|0 2|1 3|2 </riskdata> Select which table: <dropdown table="selecttable" /> Select which row: <dropdown table="selectrow" /> <riskdisplay><riskdatalookup table={table} rowindex={rowindex} /></riskdisplay>
For related features, see RiskModel documentation, RiskDisplay documentation, or DropDown documentation.