Prevent peak load spikes using constraint attribute rules

First, you'll create two attribute rules to enforce and report on data integrity in the ArcGIS Utility Network. Then, you'll use Arcade to configure and test new pop-up expressions that will derive useful information from the log you created through the calculation rule. You'll learn how to do the following:

  • Create a constraint rule to prevent spikes with peak load.
  • Create an associated calculation rule to report peak load values when edits are made to low-voltage service features.
  • Test the attribute rules by editing low-voltage service features and reviewing the output of each rule.
  • Configure a pop-up using Arcade to derive useful information from the log you created using the calculation rule.

Before getting started, you may want to review the electric data model.

Add a constraint attribute rule

In the utility network, irregular attribute edits were observed on features of the Low Voltage Service asset group. However, if you open the Electric Network Editor map or review feature classes in the UtilityNetwork feature dataset in the geodatabase containing your utility network to identify the irregularities, you may notice that a Low Voltage Service feature class is not available.

This is because the ArcGIS Utility Network implements a classification model using subtype group layers and attribute domains, which reduces the need for a large number of individual feature classes. In addition, in the Contents pane of the map, composite layers are used to group related utility network layers. These composite layers function more efficiently than individual layers by reducing the number of requests made to the data source when layers are queried, edited, or refreshed.

  1. Download the Attribute rules in the ArcGIS Utility Network project package.
  2. Locate the Attribute_rules_in_the_ArcGIS_Utility_Network_ project package on your computer. Move the file to a suitable location, if necessary, and double-click it.

    The Use Attribute Rules project opens in ArcGIS Pro.

    Note:

    If you don't have access to ArcGIS Pro or an ArcGIS organizational account, see options for software access.

  3. In the Catalog pane, expand Databases and expand electricnetworkeditor.gdb.
    Note:

    If the Catalog pane is not visible, on the ribbon, on the View tab, in the Windows group, click Catalog Pane.

  4. Under electricnetworkeditor.gdb, expand the UtilityNetwork feature dataset.

    Review the feature classes and relationship classes organized in the feature dataset. These represent the schema (structure) of the geodatabase containing the utility network.

  5. In the Catalog pane, right-click ElectricDevice, point to Data Design, and choose Subtypes.

    Subtypes view for ElectricDevice

    The Subtypes view for the ElectricDevice feature class appears. The feature class already has several subtypes and related domains applied.

  6. In the Subtypes view, review the *ASSETGROUP subtype.

    *ASSETGROUP subtype

    *ASSETGROUP is a subtype used to define various types of assets, such as a high-voltage arrester, low-voltage switch, low-voltage arrester, and low-voltage service. In addition, ASSETTYPE provides a mechanism to define a level of subclassification for an asset. For example, the Low Voltage Service is subclassified as Single Phase Residential and Three Phase Commercial.

  7. In the Subtypes view, scroll across to the Low Voltage Service column corresponding to ASSETGROUP 22.

    *ASSETGROUP 22 row for Low Voltage Service

    For the Low Voltage Service subtype, many fields have domains assigned and some fields have default values set. These enforce data integrity (valid values) by limiting updates to a specific list of choices or a range of values. If no value is provided, the default is used.

  8. For *ASSETGROUP 22, scroll down to the peakload field.

    The peakload field does not have a domain assigned.

    The peakload field

    Note:

    Peak load (or peak demand) can fluctuate many times on a daily cycle and its values can vary between services. As a result, default values and domains are not effective tools to maintain data integrity for this attribute. A solution is to author a constraint attribute rule using the Arcade global $originalFeature in the attribute rules profile that will detect large changes assigned to the peakload attribute. The $originalFeature Arcade global presents the state of the feature before the edit, giving the script author flexibility to compare the current values of $feature with the original values of the feature.

    While peak load can change on a daily basis, the value range is generally consistent day to day and should only reflect broad changes on a monthly or seasonal basis. Using a new constraint rule applied to the peakload field will trigger an edit to fail when a change to the field is too large. In a later step, you will enhance this error detection by creating a calculation attribute rule to populate a row in a table to log the changes made to the peakload field.

  9. Close the Subtypes view.

    Next, you'll add an attribute rule. Attribute rules enhance the editing experience and improve data integrity for geodatabase datasets. They are user-defined rules that can be used to automatically populate attributes, restrict invalid edits during edit operations, and perform quality assurance checks on existing features.

    Attribute rules are complementary to existing rules used in the geodatabase, such as domains and subtypes. For example, domains can be assigned to an attribute field to aid in the data collection process by providing a pick list of valid values for editors. To enhance this behavior, an attribute rule can be used to restrict values for an attribute field that are not part of the domain when performing a field calculation. After rules are added to a dataset, they can be evaluated as edits take place or at a later time.

    It's important to note that attribute rules are not specific ArcGIS Utility Network functionality but can be deployed across all geodatabase feature classes and tables to perform edit operations, data validation, quality assurance, and operations.

  10. In the Catalog pane, right-click ElectricDevice, point to Data Design, and choose Attribute Rules.

    Data Design and Attribute Rules options

    The Attribute Rules view opens. This view contains three tabs identifying different rule types: Calculation, Constraint, and Validation.

  11. In the Attribute Rules view for Calculation rules, scroll to Rule Name ID_Device_22 representing the Low Voltage Service feature.

    Low Voltage Service rule

  12. Click the rule to select it. In the ID_Device_22 pane, review the Expression and Triggers sections.

    Explore rule expression.

    When this expression is applied during insertion of a new Low Voltage Service feature, it populates the assetid field with a unique ID value.

    Next, you'll add a new constraint rule to cause edits to fail if the peak load value is modified by a factor of more than 50. Constraint rules specify permissible attribute configurations and general relationships on a feature. These prevent invalid data entry during edit operations to ensure data integrity. Constraint rules can be created for datasets in both file and enterprise geodatabases using the Add Attribute Rule and Import Attribute Rules geoprocessing tools or in the Attribute Rules view.

  13. In the Attribute Rules view, click the Constraint tab and click Add Rule.

    Add Rule option

    The New Rule pane appears. No constraint rules are defined yet.

    Next, you'll update the rule properties to create a constraint rule for the ElectricDevice feature class.

  14. In the New Rule pane, enter the following parameters:
    • For Rule Name, type Prevent load spikes.
    • For Description, type If the peak load attribute is changed by a factor of more than 50, fail the edit.
    • For Subtype, select Low Voltage Service.

    New Rule parameters

    You selected the Low Voltage Service subtype because you want this attribute rule to execute only when edits are made to service meters of this subtype.

  15. In the Prevent load spikes pane, for Expression, click the Expression button.

    Expression button

  16. In the Expression Builder window, in the Expression text box, copy and paste the following code:
    
    var dLoad = $feature.peakload - $originalFeature.peakload;
    if (dLoad > 50)
        return false;
    else
        return true;

    Arcade expression entered in Expression text box

  17. Click the Verify button to validate the expression and click OK.

    Verify and OK buttons

    Note:

    The Arcade global $originalFeature provides the state of the feature before it was edited. For example, if the current value of peakload for a feature is 10, and you update the value to 20, $originalFeature.peakload will return 10 and $feature.peakLoad will return 20.

    Next, you'll continue updating rule properties.

  18. In the Prevent load spikes pane, in the Error section, set the following parameters:
    • For Error Number, type 1001.
    • For Error Message, type Load spike detected, aborting edit.

    Error section parameters

  19. In the Triggers section, check the Update box.
  20. In the Execution section, check the Exclude from application evaluation box.

    Prevent load spikes rule parameters complete

  21. On the ribbon, on the Attribute Rules tab, in the Attribute Rules group, click Save.

    Save button

    Note:

    It may take several minutes for the rule to save.

  22. Close the Attribute Rules view.
  23. On the Quick Access Toolbar, click Save .

    Save button on the Quick Access Toolbar

Test the constraint rule

To test the new constraint rule you just created, you need to update a low-voltage service and edit the peak load.

  1. In the Catalog pane, expand Maps.
  2. Right-click the Electric Network Editor map and choose Open.

    Open option

    The Electric Network Editor map opens.

  3. On the Map tab, in the Navigate group, click Bookmarks and choose Test Attribute Rule.

    Test Attribute Rule bookmark

    The map extent updates and centers on a low-voltage service point located south of Beebe Elementary School.

    Map centered on the target feature location

  4. On the ribbon, in the Selection group, click the Select tool.

    Select tool

  5. Click the low-voltage service point.

    Target feature selected

    The feature highlights in blue, indicating it is selected.

  6. On the ribbon, in the Selection group, click Attributes.

    Attributes option

    The Attributes pane appears.

    Attributes pane for the selected feature

  7. At the bottom of the Attributes pane, confirm that Auto Apply is checked.

    Auto Apply check box

    This parameter ensures that edits to the feature are automatically applied.

  8. Locate the Peak Load (kW) attribute, type 10, and press Enter.

    Peak Load (kW) modified

    The Peak Load (kW) attribute is updated for the feature, and no warning is expected since the constraint rule applied to this field is triggered only when the value exceeds 50 kW.

  9. For Peak Load (kW), type 70 and press Enter.

    The updated Peak Load (kW) value of 70 triggers the edit to fail and an error message displays in the Attributes pane.

    Error when Peak Load updates

    The edit failure and the error message were triggered because the Peak Load (kW) value increased by more than 50 kW. This was a result of the constraint rule applied to the ElectricDevice features.

    Note:

    In the constraint rule expression, the initial $originalFeature value was set to 0. Updating it to 10 did not trigger the constraint because 10 - 0 = 10, which is less than 50. Updating the value to 70, however, triggered the attribute rule and caused the failure because 70 - 10 = 60, which is greater than the threshold value of 50.

  10. Test your constraint rule by experimenting with different values for the Peak Load (kW) attribute.
    Tip:

    Try editing the Prevent load spikes rule to prevent an error. Use the Abs() function in Arcade.

    If you lower the Peak Load (kW) value by more than 50, the error does not occur.

    For the purpose of this lesson, you won't keep the edits made to Peak Load (kW).

  11. On the Edit tab, in the Manage Edits group, click Discard to discard your edits. Click Yes to confirm.

    Discard button

  12. Close the Electric Network Editor map and save the project.

You've authored a constraint attribute rule using the Arcade global $originalFeature to detect large changes made to the peakload attribute.


Report peak load spikes using a calculation report

Previously, you authored a constraint attribute rule using the Arcade global $originalFeature to detect large changes made to the Peak Load attribute. Next, you will create a calculation rule to report the peak load value when low-voltage services are updated. The calculation attribute rule will detect a change in the service point load history and log this information in a separate table.

Create a load history table

First, you'll create a table in the electricnetworkeditor geodatabase to log the changes in service point load history.

  1. In the Catalog pane, expand Databases. Right-click electricnetworkeditor.gdb, point to New, and choose Table.

    Create a table

    The Create Table wizard appears.

  2. In the Create Table wizard, on the Define page, enter the following information:
    • For Name, type LoadHistory.
    • For Alias, type Load History.

    Create Table wizard Define page parameters

    Next, you'll add two new fields to the table.

  3. Click Next.
  4. On the Fields page, click Click here to add a new field and enter the following information:
    • For Field Name, type peakLoad.
    • For Data Type, choose Long Integer.

    Add a new field.

  5. Click Click here to add a new field to add the second field with the following parameters:
    • For Field Name, type serviceGUID.
    • For Data Type, choose GUID

    Add a second field.

    To track which services were edited, the peakLoad field will store the load of the service point and the serviceGUID field will store the GUID of the updated service point.

  6. Click Finish to create the new table.
  7. In the Catalog pane, confirm that the LoadHistory table has been successfully created.

    Next, you'll enable editor tracking on the LoadHistory table to log and identify who edits the table and when edits are made.

  8. In the Catalog pane, right-click the LoadHistory table and choose Manage.
  9. In the Table Properties window, check Editor Tracking.

    Editor tracking parameter

    Fields that support editor tracking are added to the table.

  10. Click OK to close the Table Properties.
  11. In the Catalog pane, right-click LoadHistory, point to Data Design, and choose Fields.

    The Fields view for the table appears.

    Field designer

    The fields that were added to support editor tracking include a global user identifier and fields to identify the user who generated and edited the feature and the date the edits were made.

  12. Close the Fields view.

Create a calculation attribute rule

Next, you'll create a calculation attribute rule that detects a change in the service point load history and logs this information in a separate table. Calculation attribute rules are used to automatically populate attribute configurations on a feature.

  1. In the Catalog pane, expand the UtilityNetwork feature dataset.
  2. Right-click the ElectricDevice class, point to Data Design, and click Attribute Rules.

    The Attribute Rules view appears.

  3. If necessary, in the Attribute Rules view, click the Calculation tab.

    There are several existing calculation rules. These were created during the initial configuration of the utility network and are used to maintain data integrity.

  4. Click the Add Rule drop-down arrow and choose Add Immediate Calculation Rule.

    Add Immediate Calculation Rule option

    The New Rule pane appears.

    Immediate calculation rules are automatically evaluated and triggered by edit operations such as insert, update, and delete. You'll create a rule that is triggered by insert and update operations.

  5. In the New Rule pane, enter the following parameters:
    • For Rule Name, type Log Load History.
    • For Description, type Records all changes to the peak load attribute.
    • For Subtype, choose Low Voltage Service.
    • For Field, choose peakload.

    Updating the Rule Name field updates the pane title to Log Load History.

    New Rule pane parameters

  6. In the Log Load History pane, click the Expression button to open the Expression Builder window.
  7. In the Expression Builder window, for Expression, enter the following Arcade expression:
    
    return {
             "result": $feature.peakload,
             "edit" : [
                 {
                    "className": "LoadHistory",
                    "adds": [{
                          "attributes": {"peakLoad": $feature.peakLoad, "serviceGUID": $feature.globalID }   
                        }]
                  }
               ]
    
    }

    Arcade expression in Expression Builder window

    Note:

    This script uses an edit dictionary return type, which is a special dictionary (in JSON format) that includes the following properties:

    • "result"—Represents what you want to return as the peak load of the feature you are editing. In this example, you are not altering the result. You want to return the current peakload value for the edited service feature and update the field with the same name in the LoadHistory table.
    • "edit"—Represents an array of edits that you want to make because of the initial edit. In this example, you want to edit the className field of the LoadHistory table by performing a series of "adds" functions with specified attributes.
  8. Click the Verify button to validate the script and ensure that your expression will execute correctly. Click OK.
  9. In the Log Load History pane, under Triggers, check the Insert and Update boxes.
  10. Under Execution, check the Exclude from application evaluation box.

    Triggers and Execution sections

  11. On the ribbon, on the Attribute Rules tab, in the Attribute Rules group, click Save.
    Note:

    It may take several minutes for the rule to save.

  12. Close the Attribute Rule view pane and save the project.

Test the calculation rule

To test the immediate calculation attribute rule you just created, you must update a low-voltage service by editing the peakload attribute. Then, you'll confirm that the edit was applied to the LoadHistory table through the calculation rule.

  1. In the Catalog pane, expand Maps. Double-click the Electric Network Editor map.

    The Electric Network Editor map appears.

  2. On the ribbon, click the Map tab. In the Navigate group, click Bookmarks and choose Test Attribute Rule.

    The map extent updates to the location of a low-voltage service feature.

    Select the low-voltage service.

  3. On the Map tab, in the Selection group, click the Select tool and click the low-voltage service point connected to Electric Device 1267.
  4. On the Map tab, in the Selection group, click Attributes.
  5. In the Attributes pane, verify that the selected feature has a Global ID value of {306A7664-7DDE-46EB-B415-A75F19658095}.

    Global ID attribute in the Attributes pane

  6. If necessary, check the Auto Apply box to automatically commit edits.
  7. For Peak Load (kW), type 10 and press Enter.

    As you update the Peak Load (kW) values, the new attribute rule is generating records in the LoadHistory table to track edits made to the low-voltage service points.

  8. For Peak Load (kW), type 30, and press Enter.
  9. In the Contents pane, under Standalone Tables, right-click the LoadHistory table and choose Open.

    The table has two rows representing the updates made to the peakLoad attribute. These were generated as a result of the calculation rule you created. In addition, the table includes fields containing details about the editor and the dates and times the edits were made.

    LoadHistory table

  10. Edit the Peak Load (kW) attribute for the low-voltage service point feature a few more times and confirm that the LoadHistory table updates by refreshing the table after making an edit.

    The current calculation rule configured for low-voltage service points adds a new row to the table each time a point is edited. Your new calculation rule will track every edit that occurs for the peak load of the Low Voltage Service asset group. Using the $originalFeature global, you can, for example, configure the rule to generate a log value only when the peakLoad attribute is changed.

  11. Save the project.
    Note:

    In a real-world scenario, it is likely that the load information for these services in an automated fashion. The constraint rule you created may prevent abnormal value spikes from entering the system by raising errors if this occurs.

    Your calculation rule automates the reporting of these values and provides insight into customer operational patterns and trends. Use the LoadHistory table to share this information with engineers and operations team members and to provide a resource for additional analysis if abnormal values indicate a problem.

    You can also use the LoadHistory table to provide similar analyses to your customer service staff and field crew. In this way, spatial feedback can be used when assisting customers with billing calls or inspecting devices in the field during service calls.

Next, you'll configure pop-ups to present information derived from the LoadHistory table to provide spatial feedback and assist your customer service staff and field crew when assisting customers with billing calls or inspecting devices in the field during service calls, respectively. This can provide context to the history of the service for those using this data.


Configure a pop-up to display load history

Previously, you created a calculation rule to report the peak load value when low-voltage services were updated. A calculation attribute rule detected a change in the service point load history and logged information in a table. Next, you will configure pop-ups to present the information derived from the LoadHistory table.

Display and summarize load history

As a final step, you will configure pop-ups for the Low Voltage Service asset group and create three expressions to extract and display information collected in the LoadHistory table.

  1. In the Contents pane, expand Electric Device (if necessary), right-click the Low Voltage Service sublayer, and click Configure Pop-ups.

    Configure Pop-ups

    The Configure Pop-ups pane appears.

  2. In the Configure Pop-ups pane, click Expressions to create an Arcade expression.

    Button to add a new Arcade expression

  3. Click New to open the Expression Builder window.

    New expression button

    The Expression Builder window appears.

    The first expression you will create will be used to report the maximum Peak Load (kW) value for the selected service feature from the LoadHistory table.

  4. In the Expression Builder window, enter the following parameters:
    • For Name, type Max.
    • For Title, type MaxLoad.

    The title is the display name of a virtual field used in the pop-up to display expression results.

  5. In the Expression text box, enter the following script:
    
    //Create a variable to reference the LoadHistory table
    
    var fshistory = FeatureSetByName ($datastore,"LoadHistory", ["peakload"])
    
    //Create a variable to reference the GlobalID of the selected feature in the map
    
    var GlobalID = $feature.globalID
    
    // We are interested in rows from LoadHistory.serviceGUID that match the Service feature selected.  This filters results to return only ServiceGUIDs that match the $feature.GlobalID
    
    var rows = filter(fshistory,"serviceGUID = @GlobalID")
    //Guard logic to display 0 if no values found in the LoadHistory table
    if (count(rows) == 0)return 0
    
    //Return filtered values from LoadHistory.peakload in the Low Voltage Service pop-up in bold
    
    return "<b>" +  max (rows, "peakload") + "</b>"
    Note:

    This expression uses the function max() to return the maximum value set for peak load. To return the minimum value set for peak load, you can replace max() with min().

    Expression Builder parameters for MaxLoad

  6. Click the Verify button to validate the script and ensure that your expression will execute correctly and click OK.
  7. On your own, create a second expression to report the minimum value set for Peak Load (kW) on the selected service feature from the LoadHistory table.
    Tip:

    Consider using the min() function.

    Next, you will add an expression that communicates the number of times the selected service has been edited.

  8. Click New to open the Expression Builder window.

    The first expression you will create will be used to report the maximum Peak Load (kW) value for the selected service feature from the LoadHistory table.

  9. In the Expression Builder window, enter the following parameters:
    • For Name, type Count.
    • For Title, type #Updates.
  10. In the Expression text box, enter the following script:
    
    //Create a variable to reference the LoadHistory table
    
    var fshistory = FeatureSetByName ($datastore,"LoadHistory", ["peakload"])
    
    //Create a variable to reference the GlobalID of the selected feature in the map
    
    var GlobalID = $feature.globalID
    
    // We are interested in rows from LoadHistory.serviceGUID that match the Service feature selected.  This filters results to return only ServiceGUIDs that match the $feature.GlobalID
    
    var rows = filter(fshistory,"serviceGUID = @GlobalID")
    
    //Guard logic to display 0 if no values found in the LoadHistory table
    if (count(rows) == 0)return 0
    
    //Return filtered values from LoadHistory.peakload in the Low Voltage Service pop-up
    
    return "<b>" +  count (rows) + "</b>"

    When you're finished, review the Expression Builder settings.

    Expression Builder parameters for Count

  11. Click the Verify button to validate the script and ensure that your expression will execute correctly, and click OK.
  12. Verify your expressions in the Configure Pop-ups pane.

    Pop-up expressions

    Note:

    If you did not create a MinLoad expression, your list may differ.

  13. On your own, build an expression that calculates the average value of Peak Load (kW) for the selected service feature.

    For the final line of code, use return "<b>" + max (rows, "peakload") + "</b>" and replace max with average.

  14. Save your project.

    With your pop-up expressions configured, you will confirm that expected results are being generated and displayed correctly in the pop-up window.

  15. On the Map tab, in the Navigate group, click Bookmarks and click Test Attribute Rule.

    The map extent updates to the location of a low-voltage service point.

  16. On the Map tab, in the Navigate group, click the Explore tool and select the low-voltage service point on the map with a Global ID value of {306A7664-7DDE-46EB-B415-A75F19658095}.

    Select the low-voltage service feature

    The Pop-up window for the selected low-voltage service appears.

  17. In the Pop-up window, review the expression fields.

    Review the pop-up and note the MaxLoad, MinLoad, and #Updates expression fields with their associated values derived from the LoadHistory table. In the example, the additional expression used to calculate the average peak load value of the selected feature is included.

    Expressions added in Pop-up window

    Note:

    Building on the technique you used above, you can remove the bold format from the values returned in the pop-up, or make the values stand out even more by changing the display color to red if a value exceeds a certain number. To do this, use the if-else logic and the <font color> tag in your expressions.

In this tutorial, you created a constraint attribute rule to maintain data integrity and display errors when spikes in peak load value were encountered. This provided an example of how a contain attribute rule can be used along with domains, subtypes, and contingent values to maintain data integrity in a geodatabase feature class.

You then created a table and configured a calculation attribute rule to detect a change in a service point’s peak load and log this and the feature’s GUID in the new table. With the attribute rules in place, you then created a series of pop-up expressions using Arcade to derive information from the table containing peak load history and present this information using pop-ups in ArcGIS Pro.

This lesson has provided you with the building blocks to begin creating more elaborate attribute rules in your geodatabase.

You can find more tutorials in the tutorial gallery.