I have inherited a database that is built mainly from imported excel spreadsheets. The purpose of the database is to replace a very old program we are using to track utility spending. The main problem right now is one of the excel sheets lists the meters used for each building, but not in a good format. This is the format:
That means the cost for this building is the cost of 71E minus the cost of 72E plus the cost of 316E. I have a separate table that has the costs of each meter every month, which we have been recording for several years.
I am trying to find the total cost for each building every month, by creating a query and doing some VBA, but nothing is working right now. I've been working with just the electric meters to try to get something to work, and I found this function
I then grabbed the electric meters and applied this function to them to create a query that looks like
This makes the data easier to look at, and if I filter the complete meter history table I've been looking at to just grab the electric meters I can match it against the first column. I don't know what to do about the plus and minus signs though, and I know that this isn't normalized data. I haven't really been able to find someone with a problem like mine, or a solution to get the data more normalized.
My idea right now is get all the meters in one field and have the building name repeat, then try to join on meter number and have another field with cost besides that, and then grab all the costs for each building to find the total. However I can't find a way to do this, so I am open to any ideas, especially regarding how to handle the plus and minus signs in the data. I know the data is in horrible shape, and that is a big part of why they have me replacing the old program. I'm just trying to cleanup the best I can. Thank you for all the help and please ask any questions you have!
Code:
Bldg____Electric_____Gas___Heat____Cool____Water___Sewer BLDG1___79E+231E_____40G___1H______1C______86W_____111S BLDG2___80E+232E_____39G___NULL____NULL____3W+2W___163S BLDG3___71E-72E+316E_168G__9H______20C+48C_77W_____138S BLDG4___332E_________187G__53H-52H_50C-49C_162W____183S **Notice how in bldg3 electric, it's 71E-72E+316E.
I am trying to find the total cost for each building every month, by creating a query and doing some VBA, but nothing is working right now. I've been working with just the electric meters to try to get something to work, and I found this function
Code:
Public Function SplitMeters(sPackedValue As Variant, nPos As Long) Dim sElements() As StringsElements() = Split(Nz(sPackedValue, ""), "E") If UBound(sElements) < nPos Then SplitMeters = "" Else SplitMeters = sElements(nPos) End If End Function
Code:
BLDG___METER1___METER2___METER3 BLDG1__79_______+231_____NULL__ BLDG2__80_______+232_____NULL__ BLDG3__71_______-72______+316__ BLDG4__332______NULL_____NULL__
My idea right now is get all the meters in one field and have the building name repeat, then try to join on meter number and have another field with cost besides that, and then grab all the costs for each building to find the total. However I can't find a way to do this, so I am open to any ideas, especially regarding how to handle the plus and minus signs in the data. I know the data is in horrible shape, and that is a big part of why they have me replacing the old program. I'm just trying to cleanup the best I can. Thank you for all the help and please ask any questions you have!
Comment