Microsoft
Software
Hardware
Network
Question : Total cost formula using Excel
I am writing a report using Excel 2003 where I am attempting to create a total cost formula that will sum the values of 5 fields from the FA database. The data is to be imported from tables, with the first table being a "master" table and the other 2 tables are "transaction" tables. A record must be in master table, but a corresponding record may or may not be in the other two tables. To get data into the spreadsheet, I start with the master table and use VLOOKUP to match data from the other 2 tables.
You can assume EQUIP-NO fields are 5 character integers and the cost tables all have 2 decimal places
I've written this "script" based on CA/Easytrieve Plus ver. 6.3, but don't let that fool you.
FILEA
EQUIP-NO-A KEY
FILEB
EQUIP-NO-B KEY
VALUE_FUEL_B
VALUE_FLUID_B
VALUE_MISC_B
FILEC
EQUIP-NO-C KEY
LABOR-COST-C
PARTS-COST-C
D1=EQUIP-NO-A
I. IF MATCHED (FILEA KEY (EQUIP-NO-A)
FILEB KEY (EQUIP-NO-B)
FILEC KEY(EQUIP-NO-C))
AB1 = VALUE_FUEL_B
AG1 = VALUE_FLUID_B
AL1 = VALUE_MISC_B
AQ1 = LABOR-COST-C
AV1 = PARTS-COSTS-C
ELSE
II. IF FILEA AND FILEB (no match for FILEC)
AB1 = VALUE_FUEL_B
AG1 = VALUE_FLUID_B
AL1 = VALUE_MISC_B
AQ1 = #N/A
AV1 = #N/A
ELSE
III. IF FILEA AND FILEC (no match for FILEB)
AB1 = #N/A
AG1 = #N/A
AL1 = #N/A
AQ1 = LABOR-COST-C
AV1 = PARTS-COSTS-C
ELSE
IV. IF FILEA no match for FILEB or FILEC)
AB1 = #N/A
AG1 = #N/A
AL1 = #N/A
AQ1 = #N/A
AV1 = #N/A
END-IF
END-IF
END-IF
END-IF
BA1 = AB1 + AG1+AL1+AQ1+AV1
Let me present a few scenarios
I.
VALUE_FUEL_B = 100.00
VALUE_FLUID_B = 200.00
VALUE_MISC_B = 300.00
LABOR-COST-C = 400.00
PARTS-COSTS-C = 500,00
BA1 = 100.00 + 200.00 + 300.00 + 400.00 + 500.00
BA1 = 1,500.00
IV.
VALUE_FUEL_B = #N/A
VALUE_FLUID_B = #N/A
VALUE_MISC_B = #N/A
LABOR-COST-C = #N/A
PARTS-COSTS-C = #N/A
BA1 = #N/A + #N/A + #N/A + #N/A + #N/A
BA1 = #N/A. which is cool.
but ...
II.
VALUE_FUEL_B = 100.00
VALUE_FLUID_B = 200.00
VALUE_MISC_B = 300.00
LABOR-COST-C = #N/A
PARTS-COSTS-C = #N/A
BA1 = 100.00 + 200.00 + 300.00 + #N/A + #N/A
Excel's answer is BA1 = #N/A, but in real life BA1 = 600.00
III.
VALUE_FUEL_B = #N/A
VALUE_FLUID_B = #N/A
VALUE_MISC_B = #N/A
LABOR-COST-C = 400.00
PARTS-COSTS-C = 500.00
BA1 = #N/A + #N/A + #N/A +400.00 + 500.00
Excel's answer is BA1 = #N/A, but in real life BA1 = 900.00
Does anyone have an equation to handle all four scenarios?
Thanks,
Jeff
Answer : Total cost formula using Excel
try something like
=IF(ISNA(AB1),0,AB1)+IF(IS
NA(AG1),0,
AG1)+IF(IS
NA(AL1),0,
AL1)+IF(IS
NA(AQ1),0,
AQ1)+IF(IS
NA(AV1),0,
AV1)
in BA1
Random Solutions
Sending Object Via MessageQueue
How do you import outlook express 6 messages into Windows Live Mail and have them in the proper folders?
Cannot use remote executables after I upgraded to R2
How do I migrate Exchange 2003 Public Folder to Exchange 2007 using PFMigrate?
VPN client (Check point Secure client) not able to browse to any website on the machine once connected to the VPN.
How do I remove special characters in a query?
Append from Access to SQL Server key violation on any second query
Expert Notify Thread - For Experts only (those answering questions in the MS Access Zone).
SBS 2003 Network Configuration and DCHP
How to hide a value in the report