Introduction to SubTables
A SubTable provides an edit table view for the users of your model, but which displays only a subset of a larger edit table, and may display the rows or columns in a different order from the original. In this mini-tutorial, you'll create a SubTable view.
Begin by downloading the following model as a starting point: media:California Power Plants2.ANA
After loading the model, you'll should see the following diagram:
Click on the Edit Table button for "Power Plant Data". This model contains data on 34 power plants in California of various types, a portion of which is shown here:
A user can edit this large table, but you may have certain users that need to worry only about Natural Gas plants. For these users, we can provide a SubTable containing only the rows corresponding to Natural Gas plants. We can also sort the table for them, and eliminate the Plant Type column, since it will always beset to Natural Gas.
Steps:
1. Press to enter edit mode.
2. Create a decision node titled Sort By, defined as
Choice(Plant_fields,1,false)
3. Create an index named Gas Plants, defined as
index J := subset( Power_plant_data[Plant_fields='Plant Type']='Natural Gas' ); sortIndex( Power_plant_data[Plant_fields=Sort_by, Plant_id=J ] )
This expression extracts the subset of Plant_IDs in which Plant Type is "Natural Gas". It then sorts by whichever column we've selected in Sort_by.
4. Create an index, Gas_fields, defined as a list of labels:
Plant Name |
County |
Cogen |
MegaWatts |
These are the columns we want to include in the SubTable, in the order we wish for them to appear. Notice that we have excluded Plant Type.
5. Finally, create a variable node titled Gas Plant Data, defined as
SubTable( Power_plant_data[ Plant_id=Gas_plants, Plant_fields=Gas_fields ] )
Your screen should now look like (just before you press Enter to accept the definition):
6. Press the green check button to accept the definition. Notice that the definition panel changes to a SubTable button.
7. Return to browse mode by pressing . (This is so the Choice cells will appear as drop downs when we view the edit table.
8. Press the SubTable button to bring up the SubTable edit view. You should see:
Enable comment auto-refresher