The Unit System Editor provides a table of equivalencies that enables EnergyCAP to convert between various energy types, units and commodities. By relating and harmonizing utility billing data from diverse sources, and reporting on that data using user-selected energy 'Roll-Up units' such as MMBTUs, EnergyCAP is able to provide meaningful energy information across the enterprise.
WATCH VIDEO on the Unit System (Basic Session)
WATCH VIDEO on the Unit System (Advanced Session)
The Unit System Editor interface enables the user to define the components needed to store utility billing data in EnergyCAP Enterprise. These components may also be the building blocks for other functions. Components that may be created, defined and incorporated in the Unit System Editor include:
Commodities: Goods, services, or entities that are being monitored by EnergyCAP Enterprise. Examples include electricity and natural gas, but can also include less traditional categories like wood or weather.
Types: Defines a type of observation monitored for a commodity and provides the context for that data’s usage. Example types include use, percentage and demand, but may also include taxes and cost.
Units: Define the units of measure for all commodities. You can also define conversions between units of like types (e.g., converting cubic feet to gallons) by supplying the equation to use for the conversion.
Equivalencies: Define relationships between commodities, types, and units.
All numeric data in EnergyCAP Enterprise must be assigned a Commodity, Type, and Unit. These three categories combine to form a physical definition for any piece of numeric data. Categories are further defined and related to each other using additional qualifications and groupings including:
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
What is a Common Usage Roll-Up?
ANSWER: The Common Usage Roll-Up is the default unit of measure that will be used for a commodity on reports and PowerViews when different vendors use different units for that same commodity (example: some vendors report natural gas in MCF and others report it in DKTHM). In EnergyCAP, the user can determine and/or change the Common Usage Roll-Up
What is a Global Usage Roll-Up?
ANSWER: The Global Usage Roll-Up is the default unit of measure for reports combining unlike commodities. It is the 'highest' level of energy conversion in EnergyCAP. The default unit is MMBTUs. It is generally not advisable to change this default setting, although it is possible.
How do I change the Common or Global Usage Roll-up?
ANSWER: View the topic on Changing the Common Unit Roll-Up to see the process. Changing the Global Usage Roll-Up is identical to changing the Common Unit Roll-Up except that the commodity of ENERGY is selected and the Global Roll-Up checkbox is checked (Equivalencies window, General tab).
How do Unit System decisions affect EnergyCAP reports?
ANSWER: Changes to the Common Unit Roll-Up will be reflected on most reports using that commodity. Some bill-by-bill reports may show 'native use' units, while other reports that include multiple and diverse commodities may display the Global Roll-Up unit (usually MMBTUs). ! In order for these changes to be applied to historical/existing billing data, the SQL statement at the end of the process for changing the Common Unit Roll-Up MUST be executed. !
How do Unit System decisions affect EnergyCAP bill templates?
ANSWER: Changing the Unit System values will not directly affect bill entry templates. However, historical bills created with a template for a commodity which has been changed in the Unit System will need to have the cleanbill script run (see Changing the Common Unit Roll-Up topic).
How do I set up a new commodity?
ANSWER: See Working with Commodities.
How do I create an observation type?
ANSWER: See Working with Observation Types.
How do I create or modify Equivalencies?
ANSWER: See Working with Equivalencies.
What if different vendors report the same commodity in different units?
ANSWER: The Common Roll-Up Unit will be used for reports involving multiple units for that commodity.
How do changes to the Unit System affect my historical bills?
ANSWER: See Changing the Common Unit Roll-Up topic for information regarding historical bills. Because of the way that EnergyCAP stores billing data in multiple database tables, a special script process is required to ensure that Unit System changes are applied to historical bills!
How do I create new units of measure?
ANSWER: Open the Unit System Editor and click the Units tab. Then click the Plus button under the Commodities List Box to open the Create Unit window. Follow the prompts to complete setup of the new Unit. Then select the Unit from the Commodities List Box and click the Plus button underneath the Convert To: list button. The Create Conversion window will open. Select the desired unit to convert to, and supply the conversion formulas in the fields indicated. Then click OK to save the conversion.
The Unit System Editor provides an interface for managing commodities, observation types, units of measure, and equivalencies in the EnergyCAP application.
Default Commodities, Types, Units and Equivalencies cannot be deleted. The user may only modify their Display names, NOT their Codes which are fixed.
User-created Commodities, Types, Units and Equivalencies can be deleted. The user may modify their Display names AND their Codes.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
Select the Commodities tab to manage commodities. Commodities are the energy resources supplied by utilities (e.g. natural gas, electricity, coal, etc.).
Select the Types tab to manage observation types. Observation types are used to describe individual line items from the utility bill (e.g. billed demand, fee, tax, use, etc.)
Select the Units tab to manage unit of measures. Units refer to the unit of measure associated with the commodity (e.g., kWh, gallons, cu yd., etc.)
Select the Equivalencies tab to manage unit equivalencies. Equivalencies relate the various units of measure that share the same Class.
Exit the Unit System Editor by clicking Close.
*Cleanbill is a script which reprocesses a defined set of bill data, marking the set as 'dirty' and then repopulating relevant database tables based on the newest unit conversion settings. This process updates values for native usage units, common usage units, and rollup usage units.
The Unit System Editor Commodities tab lists commodities by their code and display. Lists may be sorted by column heading simply by clicking on the heading. To reverse the sort, click the column heading once more.
NOTE: Default commodities, types, unit, and equivalency displays provided by EnergyCAP can only be edited, not deleted. User-created commodities, types, units, or equivalencies can be edited AND deleted.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
Select the Commodities tab to manage commodities.
In the Code field, enter the unique, self-defined identifier.
In the Display field, enter the name to appear throughout the system.
Click OK. The Create Commodity window closes.
NOTE: After a Commodity has been added, it is necessary to relate the commodity to other commodities (see Working with Observation Types and Working with Equivalencies), in order to produce accurate EnergyCAP usage reports involvng multiple meters and commodities.
Change the code by clearing the Code field then entering the new code. Note that the code for default commodities cannot be edited. Only user-created commodity codes can be edited.
Change the display by clearing the Display field then entering the new display.
Click OK. The Commodity Properties window closes.
Click Yes to delete the commodity.
Click No to cancel the operation.
After making your selections, exit the Unit System Editor by clicking Close.
*Cleanbill is a script which reprocesses a defined set of bill data that is marked as 'dirty' and then repopulates relevant database tables based on the newest unit conversion settings. This process updates values for common usage units and global usage units.
The Unit System Editor Types tab lists unit types by their code and display. You can sort the lists by clicking a column heading. Sort the lists in reverse order by clicking the column heading once more.
For default Types, it is only possible to edit the Display name. For user-created Types, any of the fields can be edited.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
Select the Types tab to manage observation types.
In the Code field, enter the unique, self-defined identifier.
In the Display field, enter the name to appear throughout the system.
Select the Class from the drop-down list. In EnergyCAP, the Class indicates what sort of observation is being made. It answers the question: "What is being tracked?" The number of Classes is limited and fixed.
Select the time of use from the drop-down list (applicable for time-of-use commodities).
Select the origin from the drop-down list. The number of Origins is limited and fixed.
Select the applied status from the drop-down list. There are only three statuses: Credit/Provided, Debit/Consumed and Ignore.
Click OK. The Create Type window closes.
Change the Code by clearing the Code field then entering the new code.
Change the Display by clearing the Display field then entering the new display.
Change the Class by selecting the new class from the drop-down list. In EnergyCAP, the Class indicates what sort of observation is being made. It answers the question: "What is being tracked?" The number of Classes is limited and fixed.
Change the Time of Use (TOU) by selecting the new time from the drop-down list. TOU values apply primarily to certain measurements of electricity. Note that the number of TOU options in EnergyCAP is limited and fixed.
Change the Origin by selecting the new origin from the drop-down list. The Origin option answers the question: "How is this commodity type being provided?" Note that the number of Origin options in EnergyCAP is limited and fixed.
Change the Applied status by selecting the new applied status from the drop-down list. Note that the number of Applied status options in EnergyCAP is limited and fixed. Credit/Provided would refer to a production-related Unit Type. Debit/Consumed would refer to most traditional utility billing scenarios. Ignore would indicate that production or consumption does not relate to this unit Type.
Click OK. The Type Properties window closes.
Click Yes to delete the type.
Click No to cancel the operation.
After making your selections, exit the Unit System Editor by clicking Close.
*Cleanbill is a script which reprocesses a defined set of bill data, marking the set as 'dirty' and then repopulating relevant database tables based on the newest unit conversion settings. This process updates values for native usage units, common usage units, and rollup usage units.
The Unit System Editor Units tab lists units of measure by their code and display. You can sort the lists by clicking a column heading. Sort the lists in reverse order by clicking the column heading once more. Selecting a unit displays its associated conversion factors in the Convert To pane.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
Select the Units tab to manage unit of measures.
In the Code field, enter the unique, self-defined identifier.
In the Display field, enter the name to appear throughout the system.
Select the Unit Type from the drop-down list. Note that Unit Types for default units cannot be changed. The "Type" categorization answers the question: "What is the specific property of the Commodity that is being measured by the unit?" Only user-created Unit Types are fully editable.
Click OK. The Create Unit window closes.
Modify a unit of measure by selecting the applicable unit of measure then clicking the
icon below the Units list. The Unit Properties window appears.
Change the code by clearing the Code field then entering the new code. Note that Codes for default units cannot be changed. Only user-created Unit Types are fully editable.
Change the display by placing the cursor in the Display field then updating the display information using the computer keyboard.
Change the unit type by selecting the new unit type from the drop-down list. Note that Unit Types for default units cannot be changed. The "Type" categorization answers the question: "What is the specific property of the Commodity that is being measured by the unit?" Only user-created Unit Types are fully editable.
Click OK. The Unit Properties window closes.
Delete a unit of measure by selecting the applicable unit of measure then clicking the
icon below the Units list. Note that only user-created Units can be deleted.
The Confirm window appears.
Click Yes to delete the unit of measure.
Click No to cancel the operation.
Add a conversion factor to a unit of measure by selecting the applicable unit from the drop-down list and then, in the Convert To section, clicking
. The Create Conversion window appears. Insert the conversion multiplier in the Multiply ... field. If necessary add the constant in the field provided. Then click OK to save the new conversion.
Modify a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor from the drop-down list and then, in the Convert to section, clicking
. The Conversion Properties window appears. Update the conversion multiplier in the Multiply ... field. If necessary modify the constant in the field provided. Then click OK to save the modified conversion.
Delete a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor then in the Convert to field click
. The Confirm window appears.
Click Yes to delete the conversion factor.
Click No to cancel the operation.
After making your selections, exit the Unit System Editor by clicking Close.
*Cleanbill is a script which reprocesses a defined set of bill data, marking the set as 'dirty' and then repopulating relevant database tables based on the newest unit conversion settings. This process updates values for native usage units, common usage units, and rollup usage units.
The Unit System Editor Equivalencies tab lists equivalencies by commodity, class, unit type, and default value. You can sort the lists by clicking a column heading. Sort the lists in reverse order by clicking the column heading once more.
Please note that default commodities, types, units, and equivalencies cannont be deleted from the Unit System. However, you CAN edit or delete any commodities, types, units, or equivalencies you have created. Also, default DISPLAY names CAN be edited, but the default CODES cannot be edited.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |
From the Tools menu in any module or view, select Unit System. The Unit System Editor window appears.
Select the Equivalencies tab to manage unit equivalencies.
On the General tab, complete the following:
Select a commodity from the Commodity drop-down list.
Select a class from the Class drop-down list. See Working with Observation Types for more information.
Select a unit type from the Unit Type drop-down list. See Working with Units for more information.
If this is the default, select the Default check box.
In the Types section, click the checkbox to select all types that apply to this equivalency.
In the Units section, click the checkbox to select all units that apply to this equivalency.
To assign a default unit, select the unit name, then click Make default button. An asterisk [*] appears next to the default unit.
On the Conversion tab, complete the following:
Add a conversion factor to a unit of measure by selecting the applicable unit then in the Convert To section click
. The Create Conversion window appears. Follow the instructions for Creating Conversion Factors
Modify a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor then in the Convert to section click
. The Conversion Properties window appears. Follow the instructions for Modifying Conversion Factors
Delete a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor then in the Convert to field click
. The Confirm window appears.
Click Yes to delete the conversion factor.
Click No to cancel the operation.
Click OK. The Create Equivalence window closes.
On the General tab, modify any of the following:
Select a commodity from the Commodity drop-down list.
Select a class from the Class drop-down list. See Working with Observation Types for more information.
Select a unit type from the Unit Type drop-down list. See Working with Units for more information.
Select or clear the Default check box.
In the Types section, click the checkbox to select all types that apply to this equivalency.
In the Units section, click the checkbox to select all units that apply to this equivalency.
To assign a default unit, select the unit name, then click Make default button. An asterisk [*] appears next to the default unit.
On the Conversion tab, complete the following:
Add a conversion factor to a unit of measure by selecting the applicable unit then in the Convert To section click
. The Create Conversion window appears. Follow the instructions for Creating Conversion Factors.
Modify a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor then in the Convert to section click
. The Conversion Properties window appears. Follow the instructions for Modifying Conversion Factors.
Delete a conversion factor for a unit of measure by selecting the applicable unit of measure and conversion factor then in the Convert to field click
. The Confirm window appears.
Click Yes to delete the conversion factor.
Click No to cancel the operation.
Click OK. The Equivalence Properties window closes.
Click Yes to delete the equivalency
Click No to cancel the operation.
After making your selections, exit the Unit System Editor by clicking Close.
*Cleanbill is a script which reprocesses a defined set of bill data, marking the set as 'dirty' and then repopulating relevant database tables based on the newest unit conversion settings. This process updates values for native usage units, common usage units, and rollup usage units.
This example provides the process for changing the Common Unit Roll-Up for Propane from the default of ‘lb’ to ‘GAL’. Common Unit Roll-Up is the generally reported unit of measure for all meters sharing the same commodity. Common Units are used by EnergyCAP whenever multiple vendors report commodity use in different units. Using the common unit for most reports in EnergyCAP ensures an 'apples-to-apples' comparison of use, cost, and unit cost when reporting on commodities across the enterprise. The exceptions to this rule would include cross-commodity reports that would combine diverse commodities using the Global Roll-Up Unit, and bill-by-bill reports which might report the 'native unit' determined by the bill entry template.
|
|
Editing or deleting unit system data can cause unexpected behavior in other areas. Because in some database tables, EnergyCAP stores billing data based on unit conversions in place at the time of bill entry, modifications to the unit system may require running the cleanbill* process for historical bills. |











IMPORTANT NOTE: Unit System changes will impact any bills entered AFTER the date of the change.
! Existing historical bills in EnergyCAP will need to be updated to reflect the change. ALWAYS BACK UP YOUR DATABASE PRIOR TO MAKING UNIT SYSTEM CHANGES. !
Below is a sample SQL Script that could be run from either SQL Server Query Analyzer, or via the EnergyCAP Administrator Program to update the historical bills with the new roll-up information:
UPDATE BILL
SET bill.dirty = 1
WHERE billID in (SELECT billID from billaccountmeter
WHERE billaccountmeter.commodityID = 10)
GO
--
EXEC cleanbill
This topic provides a procedure for changing the EnergyCAP global unit from the default MMBtu to another unit (Giga-Joules or equivalent kWh ).
This is most helpful for non-US EnergyCAP users who need to track Global Usage Roll-Up in units of Giga-Joules (GJ) or equivalent kWh (EKWH). To complete the procedure successfully, the user will need:
EXAMPLE: For the ‘Energy’ Type, to convert EKWH to J, multiply EKWH by 3600000 and then add a constant of 0. To convert J to EKWH, divide J by 3600000 and then add a constant of 0.
EXAMPLE 1: To convert Electric, in kWh, to Energy, in GJ, values in kWh must be multiplied by a factor of 0.00360, adding a constant of 0.
EXAMPLE 2: To convert Natural Gas, in Therms, to Energy, in GJ, values in Therms must be multiplied by a factor of 0.105587, adding a constant of 0.
NOTE: If any bills exist in EnergyCAP prior to changing the Global Usage Roll-Up units, an SQL Script (see Running Cleanbill for Historical Bills, below) will need to be applied to the EnergyCAP database to update those bills.
To change the Global Unit in EnergyCAP, follow the procedure below.
! It is recommended that a backup of the database be performed prior to making this global change. !











If there are bills in EnergyCAP that were entered prior to the Global Roll-Up Unit change, the related bill tables will NOT be automatically updated to reflect the change. Instead, the SQL Script below will need to be run on the EnergyCAP database, either using SQL Query Analyzer or the EnergyCAP Administrator program.
UPDATE BILL
SET bill.dirty = 1
GO
--
EXEC cleanbill
Adding a commodity involves changes to the Unit System in EnergyCAP. ! Great care must be taken when relating a new commodity to existing units of measure, in order to avoid errors that could potentially skew reporting on energy data! Make certain to devise and execute a quality process to verify unit system changes. Such a process could include running reports on bills using the new commodity, and comparing measurement data from multiple commodity types (and including the new commodity) in PowerView rollups for multiple places/accounts.
There are several reasons why it would be advantageous to add a new commodity. The most common is that the available commodity list does not adequately mirror the accounting structure of an organization. It may be desirable to separate out certain aspects of a commodity. For example, a "Trash" meter may not be adequate when separate reporting and/or accounting for Recycling fees is desired. Perhaps there is a need to associate more than one GL code with the Trash meter. To do this most efficiently, it may be appropriate to 'break down' a single commodity into a group of related commodities.
EXAMPLE: Your organization has six Trash meters. After setting up the new commodity, you use the Account Wizard to create six more Recycling meters, each linked to the same place and account as its counterpart Trash meter, but using the new commodity with a different GL code for your accounting purposes. 
During bill entry, the recyling charges are associated with the Recycling meters and the Trash charges are associated with the Trash meters.
Procedure:

Once the Commodity has been created, it must be associated with other Commodities, appropriate units of measure, and (where necessary) conversion factors to common units of measure used in EnergyCAP reports and PowerViews.
To define the new commodity:
Setting up Conversions
Conversions are important when it is necessary to relate the commodity’s unit of measure from one Class to another Class (i.e. Therms of Natural Gas to CCF of Natural Gas is a translation of Class Heat to Class Volume.) Also, Conversions are useful to relate units of one commodity to another through the global rollup of commodities to Energy measured by MMBTU. There are other reasons to use Conversions, but these two are the most common. If reports are not turning out as expected, there is a chance the conversions have been set up incorrectly. Or it may be necessary to ADD a conversion in order for EnergyCAP to properly report on the new commodity’s data.
The new commodity will be listed in the Template Manager (Accounting>Templates). Create the new template to match the invoice received from the vendor. If difficulties are encountered, it may be necessary to revisit the Unit System Editor and verify the units of measure and Classes associated with the commodity. Contact EnergyCAP, Inc. for additional assistance.
To ensure that the Commodity has been set up correctly:
Issue: When setting up a bill entry template, the desired Unit of Measure is not a choice in the drop-down list.
EXAMPLE 1: Creating HGAL Unit
In this example, it is necessary to create a new unit of measure for sewer usage--HGAL (hundreds of gallons)--because HGAL is the “native” unit of measure shown on the bill. 
Solution: Create a new usage unit for sewer as follows:







EXAMPLE 2: Creating a new EKWH (Equivalent Kilowatt-Hours) Unit




An obvious followup question is “Why aren’t all units of measure turned on for every commodity all the time?” If every possible option was available, drop-down selector lists would be unwieldy and unmanageable, increasing the opportunity for configuration errors. EnergyCAP just shows commonly used choices and allows you to configure those options that are uncommon. This is a quick a one-time configuration.
*Cleanbill updates the BillAccountMeter (BAM) table in EnergyCAP with the most current conversion factors, ensuring the accuracy and currency of most EnergyCAP reports.
The UnitConversion table contains the factors to convert between units of the same unit type (heat, volume, length, etc.).
The Community table lists all the valid commodity-noun-unit type-unit combinations, and identifies which are the common (for each commodity-noun-unit type grouping) and global (for usage only, across all commodities and unit types) unit rollup combinations (e.g. for natural gas-usage-heat, therm, dkthm, kbtu and mmbtu are valid units, but dkthm is the common unit; for natural gas-usage-volume, cf, ccf and mcf are valid units, but mcf is the common unit, ...).
The Equivalence table contains the factors to convert between unit types and units with the same commodity and noun (use, demand, etc.) - common rollups, and between unit types and units with different commodities and nouns - global rollup.
Specifically for CleanBill, the conversions are used in this way:
-- nativeUse, noun 26 = use, observation type NULL = normal use (not generation, transmission, etc.), credit 1 = positive value, credit 2 = negative value, credit 3 = informational value (not included in computation)
BodyLine.value * (abs(observationtype.credit - 2) * 2 - 1) * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS nativeUse,
--nativeUnit
BodyLine.unitID * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS nativeUnitID,
--commonUse
((((bodyline.value * U.multiplier) + U.offset) * e1.multiplier) + e1.offset) * (abs(observationtype.credit - 2) * 2 - 1) * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS commonUse,
--commonUnit
C2.unitID * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS commonUnitID,
--globaluse
((((((bodyline.value * U.multiplier) + U.offset) * e1.multiplier) + e1.offset) * e2.multiplier) + e2.offset) * (abs(observationtype.credit - 2) * 2 - 1) * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS globalUse,
--globalUnit
C3.unitID * case when ((ObservationType.noun = 26) AND (ObservationType.creation IS NULL) AND (ObservationType.credit <> 3)) then 1 else null end AS globalUnitID,
--nativeDemand, noun 10 = actual demand, observation type NULL = normal use (not generation, transmission, etc.), credit 1 = positive value, credit 2 = negative value, credit 3 = informational value (not included in computation)
BodyLine.value * (abs(observationtype.credit - 2) * 2 - 1)* case when (ObservationType.noun = 10) AND (ObservationType.credit <> 3) then 1 else null end AS nativeDemand,
--nativeDemandUnit
BodyLine.unitID * case when (ObservationType.noun = 10) AND (ObservationType.credit <> 3) then 1 else null end AS nativeDemandUnitID,
--commonDemand
((((bodyline.value * U.multiplier) + U.offset) * e1.multiplier) + e1.offset) * (abs(observationtype.credit - 2) * 2 - 1)* case when (ObservationType.noun = 10) AND (ObservationType.credit <> 3) then 1 else null end AS commonDemand,
--commonDemandUnit
C2.unitID * case when (ObservationType.noun = 10) AND (ObservationType.credit <> 3) then 1 else null end AS commonDemandUnitID,
--nativeBillDemand
BodyLine.value * (abs(observationtype.credit - 2) * 2 - 1)* case when (ObservationType.noun = 2) AND (ObservationType.credit <> 3) then 1 else null end AS nativeBillDemand,
--nativeBillDemandUnit
BodyLine.unitID * case when (ObservationType.noun = 2) AND (ObservationType.credit <> 3) then 1 else null end AS nativeBillDemandUnitID,
--commonBillDemand
((((bodyline.value * U.multiplier) + U.offset) * e1.multiplier) + e1.offset) * (abs(observationtype.credit - 2) * 2 - 1)* case when (ObservationType.noun = 2) AND (ObservationType.credit <> 3) then 1 else null end AS commonBillDemand,
--commonBillDemandUnit
C2.unitID * case when (ObservationType.noun = 2) AND (ObservationType.credit <> 3) then 1 else null end AS commonBillDemandUnitID
Below is a sample portion of the Cleanbill script:
FROM
(bill
JOIN
bodyline ON bill.billid = bodyline.billid
LEFT JOIN
(meter
JOIN
logicaldevice on meter.logicaldeviceid = logicaldevice.logicaldeviceid) ON bodyline.meterid = meter.meterid
LEFT JOIN
unit ON bodyline.unitID = unit.unitid
LEFT JOIN
unittype ON unittype.unittypeid = unit.unittypeid
LEFT JOIN
observationtype ON bodyline.observationtypeid = observationtype.observationtypeid
LEFT JOIN
noun ON noun.nounid = observationtype.noun)
LEFT JOIN
community c1 ON c1.commodityid = bodyline.commodityid AND c1.nounid = noun.nounid AND c1.unittypeid = unittype.unittypeid
LEFT JOIN
community c2 ON c2.commodityid = bodyline.commodityid AND c2.nounid = noun.nounid AND c2.commondefault = 1
LEFT JOIN
community c3 ON c3.globaldefault = 1
LEFT JOIN
unitconversion U ON U.fromUnit = bodyline.unitid AND U.toUnit = c1.unitid
LEFT JOIN
equivalence e1 ON e1.fromCID = c1.communityID AND e1.toCID = c2.communityID
LEFT JOIN
equivalence e2 ON e2.fromCID = c2.communityID AND e2.toCID = c3.communityID