Unit of Measure Conversions

bschwartz

Well-known Member
Joined
Jan 5, 2013
Messages
1,367
Hello friends,

I would appreciate some assistance simplifying a formula for converting units of measure. We have a database called the item master file which contains item codes, descriptions, and various attributes associated with each item. When you import that database to Excel, the items codes run down the rows, and the attributes across the columns in a typical database structure. The item master file has a primary unit of measure, against which all other conversions and calculations take place called the stock unit of measure (or Stock_UM). Examples of units of measure are Pc (piece), Ea (Each), Lb (Pound), Cs (Case), Bx (Box), or Ctr (Container).

There is allowance within the item master file to setup up to two conversions to alternate units of measure (example from Box to Lbs or pieces). An item can have anywhere from 0 to 2 conversions, and if it has one conversion, that can be set up in any of the two conversion slots. Each conversion factor requires (3) variables.


  1. An alternate unit of measure
  2. A conversion factor
  3. A math operation (either multiply or divide the stock UM by the conversion factor to reach the alternate unit of measure)

For example, if the stock unit of measure is LBs and there is 18 LBs in a Box,
  1. Alternate unit of measure would be box
  2. Conversion factor would be 18
  3. Math operation would be multiply.
Multiplication because you need to multiply the stock UM (pounds) by 18 in order to get to a box.

The Item Master will look something like this:


Excel 2010
ABCDEFGHI
1ITEM_NUMBERDESCRIPTION_1UM_STOCKSUB_UNIT_OF_MEASURESUB_UNIT_FUNCTIONSUB_CONVERSION_FACTORSUB_UNIT_OF_MEASURE2SUB_UNIT_FUNCTION2SUB_CONVERSION_FACTOR2
20100Widget 1CTRM0M0
30101Widget 2PCM0M0
40102VWidget 3BXPCD12M0
50103Widget 4LBPCM3BX M18
60107Widget 5LBBXM18PC M3
70107DWidget 6LBBXM18PC M3
80107MWidget 7LBBXM3M0
90108Widget 8LBPCM2.5BX M5
100109Widget 9LBPCM2.5BX M5
110110Widget 10BXPCD12M0
120113Widget 11LBPCM1.1BX M3
130200Widget 12LBBXM10PC M0.5
140201Widget 13LBBXM30PC M5
1502013Widget 14LBBXM18M0
16020132Widget 15BXLBD6M0
1702014Widget 16LBBXM20M0
1802018Widget 17BXPCD12M0
1902018SWidget 18BXPCD24M0
200201PWidget 19BXPCD12M0
Item_Master


With that explanation in mind, it frequently happens that you are handed a report that uses a specific unit of measure, but you need to convert everything back into the stock unit of measure in order to perform additional functions on the data or to get everything into a single unit of measure, such as pounds.

For example, a sales report given in units sold might look like this (descriptions and sales data are fictitious):


Excel 2010
ABCD
1Item CodeItem DescriptionUOM PricingQty Shipped
20100Widget 1CTR75,232
30101Widget 2PC143,596
40102VWidget 3PC136,619
50103Widget 4LB133,651
60107Widget 5LB24,318
70107DWidget 6LB112,987
80107MWidget 7LB208,416
90108Widget 8LB15,151
100109Widget 9LB108,021
110110Widget 10PC59,528
120113Widget 11LB36,596
130200Widget 12LB87,931
140201Widget 13LB102,379
1502013Widget 14LB8,318
16020132Widget 15BX46,717
1702014Widget 16LB78,234
1802018Widget 17PC72,656
1902018SWidget 18PC40,505
200201PWidget 19PC83,528
Sales Data


To convert back into the stock UM, I am using the following logic:

  • If unit of measure = Stock UM, Qty Shipped (D2)
  • Otherwise, check for a match to the sub conversion UM.
    • If it is a match multiply or divide by the sub conversion factor
    • Multiply or divide based on the sub conversion function
      • M for multiply
      • D for Divide
  • If there is no match, look for a match to the sub conversion unit2
    • Repeat steps from sub conversion unit above

The formula I am using is in column F below:


Excel 2010
ABCDEF
1Item CodeItem DescriptionUOM PricingQty ShippedStock UMSales Stock UM
20100Widget 1CTR75,232CTR75,232
Sales Data
Cell Formulas
RangeFormula
E2=VLOOKUP($A2,Item_Master!$A$2:$K$936,COLUMN(Item_Master!C$1),0)
F2=IF($C2=VLOOKUP($A2,Item_Master,COLUMN(Item_Master!C$1),0),$D2,IF($C2=VLOOKUP($A2,Item_Master,COLUMN(Item_Master!D$1),0),CHOOSE(VLOOKUP(VLOOKUP($A2,Item_Master,COLUMN(Item_Master!E$1),0),{"M",1;"D",2},2,0),$D2*VLOOKUP($A2,Item_Master,COLUMN(Item_Master!F$1),0),$D2/VLOOKUP($A2,Item_Master,COLUMN(Item_Master!F$1),0)),IF($C2=VLOOKUP($A2,Item_Master,COLUMN(Item_Master!G$1),0),CHOOSE(VLOOKUP(VLOOKUP($A2,Item_Master,COLUMN(Item_Master!H$1),0),{"M",1;"D",2},2,0),$D2*VLOOKUP($A2,Item_Master,COLUMN(Item_Master!I$1),0),$D2/VLOOKUP($A2,Item_Master,COLUMN(Item_Master!I$1),0)))))


This formula works fine, but it's a bit complex, and I am hoping someone here can help me to simplify it.

Thanks very much.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Ben

It seems to me that you have a named range "Item_Master" being (at least) all the data rows and columns A:I on the 'Item_Master' sheet.

In that case, try these formulas on the 'Sales Data' worksheet.

E2:
Code:
=VLOOKUP($A2,Item_Master,3,0)

F2:
Code:
=IF(C2=E2,D2,IF(VLOOKUP(A2,Item_Master,4,0)=C2,D2*(VLOOKUP(A2,Item_Master,6,0))^(1-2*(VLOOKUP(A2,Item_Master,5,0)="D")),D2*(VLOOKUP(A2,Item_Master,9,0))^(1-2*(VLOOKUP(A2,Item_Master,8,0)="D"))))
 
Upvote 0
That's totally brilliant, thank you!!

And yes, that table is named Item_Master. I apologize; I neglected to mention that.
 
Upvote 0
Glad it worked for you. Thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top