Showing posts with label SUMIF. Show all posts
Showing posts with label SUMIF. Show all posts

SumIf vs Pivot Table


Earlier this week I received an email from Raj. He was new to Excel and had a problem he could not figure out. Raj had a list of accounts and was trying to get the total quantity of purchase orders and the total value of the purchase orders for each account. The problem he was having was that there were multiple lines for each account (based on the fiscal month). Here is a sample the data he had.


A
B
C
D
1
Account Number
Fiscal Month
Number Of Purchase Orders
Total PO Value
2
1000002
Jan
3
1864
3
1000004
Jan
5
3232
4
1000009
Jan
4
4469
5
1000004
Feb
1
3368
6
1000007
Jan
6
3675
7
1000009
Feb
2
2953
8
1000005
Jan
4
5994
9
1000009
Mar
1
4812
10
1000001
Jan
3
5221
11
1000008
Jan
4
5126
12
1000007
Feb
2
5812
13
1000002
Feb
5
3334
14
1000005
Feb
4
4398
15
1000008
Feb
4
2948
16
1000005
Mar
1
2184
17
1000002
Mar
6
3670

I have highlighted the accounts above to help show the multiple rows.

Well there are a few ways to solve this problem.  To start I want to have a column with just a list unique accounts (no duplicates).

F
Account Number
1000001
1000002
1000004
1000005
1000007
1000008
1000009

I then can use the SUMIF formula to solve Raj’s problem.

F
G
H
I
J
Account Number
PO Order Total
formula
 PO Total Value
formula
1000001
3
=SUMIF(A:A,F7,C:C)
         5,221.00
=SUMIF(A:A,F7,D:D)
1000002
14
=SUMIF(A:A,F2,C:C)
         8,868.00
=SUMIF(A:A,F2,D:D)
1000004
6
=SUMIF(A:A,F3,C:C)
         6,600.00
=SUMIF(A:A,F3,D:D)
1000005
9
=SUMIF(A:A,F6,C:C)
       12,576.00
=SUMIF(A:A,F6,D:D)
1000007
8
=SUMIF(A:A,F5,C:C)
         9,487.00
=SUMIF(A:A,F5,D:D)
1000008
8
=SUMIF(A:A,F8,C:C)
         8,074.00
=SUMIF(A:A,F8,D:D)
1000009
7
=SUMIF(A:A,F4,C:C)
       12,234.00
=SUMIF(A:A,F4,D:D)
55
       63,060.00

So what is this formula doing? For the PO Total column the sumif formula takes the account number in column F and then looking in column A for the match. It then sums all the values in column C that have the match.

 Now I could also create a simple pivot table to solve Raj’s problem.



















Both provide the answer Raj is looking for. Want to see more? Download the example here.


Cash register information - What was the original price before discount?

Today I want to break away from how Excel accomplishes things (well kind of) and focus on an example of how you can use Excel.

In today’s example I have receipts from Tom’s Appliance Store. Sales were slow at Tom’s so they decided to have a one day 10% off all purchased items sale. They had 3 sales that day (told you things were slow). Each sale consisted of items applicable fees for the purchased items.

Now a typical Tom’s Appliance Store receipt will have a date, receipt #, Item # and description as well as shown cost of item. Indeed here is the sample data…


A
B
C
D
E
F
1
Date Of Sale
Cash Register Receipt #
Item #
Description
 Cash Register Shown Amount
 Item Quantity
2
6/21/2012
12345
1
Delivery fee
                 100.00
                1
3
6/21/2012
12345
18
Stove
                 975.00
                1
4
6/21/2012
12345
19
Microwave
                 450.00
                1
5
6/21/2012
13579
17
Refrigerator
             1,200.00
                1
6
6/21/2012
13579
23
Trash Compactor
                 260.00
                1
7
6/21/2012
24680
1
Delivery fee
                 100.00
                1
8
6/21/2012
24680
20
Dishwasher
                 375.00
                1
9
6/21/2012
24680
21
Sink
                 200.00
                1
10
6/21/2012
24680
22
Faucet
                 150.00
                1

On its own this data is not very informative. It does not tell how much each cash register receipt total was. Nor does it tell what the original price of the item was or how much discount was applied at an item or ticket level.

This is a perfect opportunity for Excel to shine and a good example of how you can utilize Excel to obtain this information knowing only a few basic calculations.

First off I want to know the total of every register receipt. Now I could just manually add each receipt placing the value in a new column but I can use the =sumif formula to automatically calculate my result.

I start by adding a header in column G “Total Cash Register Receipt” and use the =sumif function to automatically calculate my answer. Sum If will check my Cash Register Receipt column (B:B) and for every receipt number (B2 or B3, or B4…), sum the Cash Register Shown Amount (E:E).

A
B
C
D
E
F
G
Date Of Sale
Cash Register Receipt #
Item #
Description
Cash Register Shown Amount
Item Quantity
Total Cash Register Receipt
6/21/2012
12345
1
Delivery fee
100
1
=SUMIF(B:B,B2,E:E)
6/21/2012
12345
18
Stove
975
1
=SUMIF(B:B,B3,E:E)
6/21/2012
12345
19
Microwave
450
1
=SUMIF(B:B,B4,E:E)
6/21/2012
13579
17
Refrigerator
1200
1
=SUMIF(B:B,B5,E:E)
6/21/2012
13579
23
Trash Compactor
260
1
=SUMIF(B:B,B6,E:E)
6/21/2012
24680
1
Delivery fee
100
1
=SUMIF(B:B,B7,E:E)
6/21/2012
24680
20
Dishwasher
375
1
=SUMIF(B:B,B8,E:E)
6/21/2012
24680
21
Sink
200
1
=SUMIF(B:B,B9,E:E)
6/21/2012
24680
22
Faucet
150
1
=SUMIF(B:B,B10,E:E)

Date Of Sale
Cash Register Receipt #
Item #
Description
 Cash Register Shown Amount
 Item Quantity
Total Cash Register Receipt
6/21/2012
12345
1
Delivery fee
    100.00
             1
       1,525.00
6/21/2012
12345
18
Stove
    975.00
             1
       1,525.00
6/21/2012
12345
19
Microwave
    450.00
             1
       1,525.00
6/21/2012
13579
17
Refrigerator
 1,200.00
             1
       1,460.00
6/21/2012
13579
23
Trash Compactor
    260.00
             1
       1,460.00
6/21/2012
24680
1
Delivery fee
    100.00
             1
          825.00
6/21/2012
24680
20
Dishwasher
    375.00
             1
          825.00
6/21/2012
24680
21
Sink
    200.00
             1
          825.00
6/21/2012
24680
22
Faucet
    150.00
             1
          825.00

Great start! Now I know what my total Cash Register Receipt is but this amount already had the 10% discount applied. I want to know what the original price of each item was as well as the original price of each cash register receipt.

Well to get that I need to go back to my high school math Algebra days.

The formula to figure this out is:  Cash Register Shown Amount / (1.0 – 10% discount)

Let’s start by adding two more columns (Original Item Price and 10% Discount

A
B
C
D
E
F
G
H
I
Date Of Sale
Cash Register Receipt #
Item #
Description
Cash Register Shown Amount
Item Quantity
Total Cash Register Receipt
Original Item Price
10% discount

I place my discount of 10 percent in each cell of column I (.1). I can then use the following formula in cell H2.
=E2/(1-I2)

C
D
E
F
G
H
I
Item #
Description
Cash Register Shown Amount
Item Quantity
Total Cash Register Receipt
Original Item Price
10% discount
1
Delivery fee
100
1
=SUMIF(B:B,B2,E:E)
=E2/(1-I2)
0.1
18
Stove
975
1
=SUMIF(B:B,B3,E:E)
=E3/(1-I3)
0.1
19
Microwave
450
1
=SUMIF(B:B,B4,E:E)
=E4/(1-I4)
0.1
17
Refrigerator
1200
1
=SUMIF(B:B,B5,E:E)
=E5/(1-I5)
0.1
23
Trash Compactor
260
1
=SUMIF(B:B,B6,E:E)
=E6/(1-I6)
0.1
1
Delivery fee
100
1
=SUMIF(B:B,B7,E:E)
=E7/(1-I7)
0.1
20
Dishwasher
375
1
=SUMIF(B:B,B8,E:E)
=E8/(1-I8)
0.1
21
Sink
200
1
=SUMIF(B:B,B9,E:E)
=E9/(1-I9)
0.1
22
Faucet
150
1
=SUMIF(B:B,B10,E:E)
=E10/(1-I10)
0.1

C
D
E
F
G
H
I
Item #
Description
 Cash Register Shown Amount
 Item Quantity
Total Cash Register Receipt
 Original Item Price
10% discount
1
Delivery fee
           100.00
          1
         1,525.00
           111.11
10%
18
Stove
           975.00
          1
         1,525.00
       1,083.33
10%
19
Microwave
           450.00
          1
         1,525.00
           500.00
10%
17
Refrigerator
       1,200.00
          1
         1,460.00
       1,333.33
10%
23
Trash Compactor
           260.00
          1
         1,460.00
           288.89
10%
1
Delivery fee
           100.00
          1
            825.00
           111.11
10%
20
Dishwasher
           375.00
          1
            825.00
           416.67
10%
21
Sink
           200.00
          1
            825.00
           222.22
10%
22
Faucet
           150.00
          1
            825.00
           166.67
10%

Now I know my original price before the 10% discount.

With that information I can simply subtract the Original Item Price from the Cash Register Shown Amount to find out how much of a discount was given per item.

I can also use the same =sumif function above to determine the original Receipt price but this time using column H instead of column E in my formula.

Finally I can see how much discount was applied to the entire cash register receipt by simply subtracting the Original Cash Register Receipt Price to the Total Cash Register Receipt (after the 10% had been taken off).

D
E
F
G
H
I
J
K
L
Description
 Cash Register Shown Amount
 Item Quantity
Total Cash Register Receipt
 Original Item Price
10% discount
 Discount Applied per item
 Original Cash Register Receipt Price
 Original To Discount Cash Register Amount
Delivery fee
           100.00
          1
         1,525.00
           111.11
10%
        11.11
         1,694.44
                  169.44
Stove
           975.00
          1
         1,525.00
       1,083.33
10%
      108.33
         1,694.44
                  169.44
Microwave
           450.00
          1
         1,525.00
           500.00
10%
        50.00
         1,694.44
                  169.44
Refrigerator
       1,200.00
          1
         1,460.00
       1,333.33
10%
      133.33
         1,622.22
                  162.22
Trash Compactor
           260.00
          1
         1,460.00
           288.89
10%
        28.89
         1,622.22
                  162.22
Delivery fee
           100.00
          1
            825.00
           111.11
10%
        11.11
            916.67
                    91.67
Dishwasher
           375.00
          1
            825.00
           416.67
10%
        41.67
            916.67
                    91.67
Sink
           200.00
          1
            825.00
           222.22
10%
        22.22
            916.67
                    91.67
Faucet
           150.00
          1
            825.00
           166.67
10%
        16.67
            916.67
                    91.67

So here is your challenge. How would you modify the above formula(s) to accommodate changes in item quantity?