Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

Create an excel formula for "buy one, get the rest 50% off"

I need to create a formula in excel that will kind of do a "buy one item, get the rest at 50% off".

I need excel to pick the most expensive item and charge it at full value, then charge the rest at 50% of their value:

Item A=$30 Item B=$21

If on day one, item A was bought 2 times, and then item B was used once, I need excel to pick out the most expensive item of the day (which would be item A) and charge it at 100% of its value ($30) and then the for the second item A, charge it at 50% of its value ($15) and item B would also be at 50% of its value ($10.5). So the total charge for the day would be $55.50.

I have set up names for each item that correlates to its price. If I put =sum(itemA) in a cell in excel, then it comes up with 30.

I have it set up so that I can put in the number of each item that was bought and excel can multiple it for me =sum(itemA*2)-->60. I just need to figure out the 50% discount for all of the items bought in one day.

Please help, and let me know if there is anymore info that I need to share!!!!

ADDITIONAL: I have added three items using the name function under "define name". Item A is equal to 30, item B equal to 21, item C equal to 15. So this is what I have set up for example, for day one:

Item                  Quantity            Total price
item A                    2                    60 =sum(itemA*2)
item B                    1                    21 =sum (itemB*1)
item C                    0                     0 =sum (itemc*0)

total daily charges: 81 =sum(C2:C4) total daily charges with discount: 55.5 (THIS IS WHERE I NEED THE FORMULA!)

ADDITIONAL: Ok, so after working with this formula, I have another question:

I have two set of this data, and excel will pick the most expensive of the two sets and charge 100% and then charge the rest at 50%. However, I now need a way to separate out the charges for the two sets of data and get their total. So example: Item A=30, item B=21, item C=15

Set one: item A used 2x, item B used 1x Set two: item B used 1x, item C used 1x

Excel picks item A (as this is the highest in both sets) and charges it at 100% (30), then charges the rest of the items at 50% (43.5). The total that is charged is 73.5

Now I need excel to separate out the charges by set. So set one, the charge is 55.5 set two, the charge is 18.

Please let me know if additional details are needed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Assuming a layout as A:e below, three added columns might suit, with:

in F2: =MAX(IF(A:A=G2,C:C))
in G2: =IF(A2<>A3,A2,"")
in H2: =IF(G2=0,"",0.5*SUMIF(A:A,G2,E:E))+F2/2

each copied down to suit.

SO21712210 example

The first an array formula so entered with Ctrl+Shift+Enter.

The first identifies the daily maximum unit price (before discount).
The second to identify the daily summary.
The third for the calculations (same approach as @Ron Rosenfeld).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...