Excel formula for conditionally counting prices? - excel

I'm trying to write a (what I assume should be rather simple) excel formula and having quite some difficulty getting it to work... Basically I want to:
Divide value of a cell by 3
For each group of 3 return x, for each remainder return y
Find the sum of x and y
So say I'm selling raffle tickets for $40 each, but if someone buys three the price drops to $100 for that three, and the next one is back to $40 until they reach another pack of 3...
Ex.
1 would cost 50, 2: 40, 3: 100, 4: 140 5:180, 6: 200 and so on and so forth...
Any help is greatly appreciated, excel formuals are really not my strong suite :/ If it were another programming language it would be so much easier I think...

I think you could use the following formula:
First set the price and discount info in range B1:B3.
Write this formula in cell B6: =B5*B1-QUOTIENT(B5,B2)*B3 (use comma instead of semicolon (as shown on screenshot) if you're not working on a Danish computer like I am).
The price in cell B6 then updates when you adjust the number of tickets you want to buy in cell B5.
Best regards,
Simon

Related

(Excel) How to return column header of the nth highest values with formula

Given a table like this one below:
David
Mike
Lisa
David
50
10
40
Mike
0
50
50
Lisa
10
40
50
I'm trying to come up with a column of formulas and information that will automatically rank and label. See below for a correct output example.
Chosen Row ->
Mike (this cell is defined by the user)
Rank
Number
Mike
50
Lisa
50
David
0
Basically the user should be able to change the top right cell and have the rest of the table automatically adjust based on that input.
Here, the user input "Mike" into the cell, so the formulas should look into the row labeled "Mike" (with the values 0, 50, and 50 in that order) and tell me a list of the highest scoring column names, along with their scores.
The only thing that is tripping me up is integrating something into the formula that makes it skip names it has already put into the rank list. As you can see, there are 2 scores of 50 there.
There is a page for this on Microsofts website on dealing with ties, but I don't fully grasp their example where they use Countif, so I have not been able to translate it over for my purposes. They also use rank numbers to the left of the names in their example, but I'd prefer that not be necessary if possible. I don't mind writing the cell formulas by hand if auto-fill doesn't help me with certain aspects.
I know there is a way to accomplish this. I've played with the formulas and did a lot of research. I've just about resorted to coding it all in VBA, but I feel like that would be far more work. At this point I'm so close, I feel like I'm just missing one critical element.
If one has the dynamic formula in Office 365 then we can use SORT:
=SORT(CHOOSE({1,2},TRANSPOSE(B1:D1),TRANSPOSE(INDEX(B2:D4,MATCH(H1,A2:A4,0),0))),2,-1)
And Excel will spill the results correctly.
For older we need two formula:
First get the values in order:
=LARGE(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0),ROW(ZZ1))
Put that in H2 and copy down.
Then we need to reference those value to get the correct name:
=INDEX($B$1:$D$1,AGGREGATE(15,7,(COLUMN(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0))-MIN(COLUMN(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0)))+1)/(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0)=H2),COUNTIF($H$2:H2,H2)))
Put that in G2 and copy down.
I made in excel 2016, but I think it works in all versions. First I created a Rank, then I used the Index function. Download the file here:
https://1drv.ms/x/s!Apn_2zN0NfqFhWT-OdNazVTlxI2n?e=WsZLuH
Code for Rank using array formula:
=MATCH(LARGE(INDIRECT("B"&$K$1&":D"&$K$1)+COLUMN(INDIRECT("B"&$K$1&":D"&$K$1))/100000,ROW()-2),
INDIRECT("B"&$K$1&":D"&$K$1)+COLUMN(INDIRECT("B"&$K$1&":D"&$K$1))/100000,0)

Excel counting issue

I'm working on this example sheet and I'm having trouble.
Specifically, I want to know how many different people may be scoring the same result. I need to know the function because it needs to be applied on a much, much larger scale.
For example, persons c, d, and e, all had total scores of 23. Persons f and g both had total scores of 26. Person a had a total score of 75. I need to show that 3 people scored 23, 2 people scored 26, and 1 scored 75.
I've linked the sheet I'm playing around in to work out the function, so any help would be hugely appreciated.
What you're looking for is found here.
Use =COUNTIF(*range*, *value*)
I think I worked out an adequate work-around.
Sorted column a alphabetically and used a "=IF(A45=A44,"",SUMIF($A$3:$A$65,A45,$B$3:$B$65))" to avoid repeating the same total being printed, over and over, for all players, allowing me to use =UNIQUE and then =COUNTIF to identify the unique scores and how many people scored particular scores.
Didn't really want to sort, but it will have to do.
No need to sort the data with this formula:
=IF(COUNTIF($A$3:$A3,$A3)<>1,"",SUMIF($A$3:$A$65,$A3,$B$3:$B$65))
The formula shows the total score for each player only the first time that a player appears in column A. The formula assumes your data is in range $A$3:$B$65 (change as needed).
Note the missing $ in COUNTIF($A$3:$A3,$A3)
To try, just enter the formula in cell C3 (or any other column at row 3) and copy down to the last row of your data.

Forgotten how to achieve this: distinct counts from data based on a lookup value

SEE BELOW FOR THE ANSWER.
I remember solving this with an array formula a while back, but I haven't got the original workbook any more and the answer is completely escaping me.
Here's sample data:
Salesman Product
Bill Apple
Bob Orange
Bill Banana
Bob Apple
Bill Apple
Bob Orange
Bill Apple
What I'm wanting to do is make another table with the number of DISTINCT items Bob and Bill have sold. i.e:
Salesman Distinct Items
Bill 2
Bob 2
I remember using the array formula trick with IF to build an array based on a lookup value, but for the life of me I can't figure out how I then applied a distinct count to that subsequent array. It was something to do with FREQUENCY, but that only works with numbers and I haven't even been able to replicate that when I've tried just numbers. Here I've played around with both SUM(1/COUNTIF(RANGE,RANGE)) and SUMPRODUCT(1/COUNTIF(RANGE,RANGE)).
Specifically, with Bill in D2 and Bob in D3 I've arrived at this array formula (placed in E2 and E3):
{=SUM(IF($A$2:$A8=D2,1/COUNTIF($B$2:$B8,$B$2:$B8)))}
(D3 is obviously substituted for D2 in cell E3.)
It's still way off, though. I'm using Evaluate Formula to trace it and I can see that the COUNTIF counts all the occurrences of each item, not just the ones belonging to the lookup.
Any pointers back in the right direction? It's really frustrating given that I cracked it once in the past.
(I realise with Excel 2013 I can do it with Distinct Count in a PivotTable, but I'm needing to do it outside of one here for a couple of reasons.)
Thanks in advance.
EDIT - FOUND IT - SEE ANSWER BELOW
Answering my own question so that it will show up as having been resolved.
I went searching and came across this:
http://www.mrexcel.com/forum/excel-questions/706444-function-formula-excel-count-unique-values-matching-criteria.html
Here is the formula:
=SUM(IF(FREQUENCY(IF($A$2:$A$8=D2,MATCH($B$2:$B$8,$B$2:$B$8,0)),IF($A$2:$A$8=D2,MATCH($B$2:$B$8,$B$2:$B$8,0)))>0,1))
I don't know how I did it before, but I'll take whatever I can get after facepalming all day on this.
You can try this array formula:
=SUM(IF(ROW($C$2:$C$6)-ROW($C$2)+1=IFERROR(MATCH($C$2:$C$6;IF($B$2:$B$6=A2;$C$2:$C$6);0);0);1;0))
Names in B2:B6, products in C2:C6 and name to look for in A2
Depending on your regional settings you may need to change field separator ";" by ","

Conditional IF Statement in Excel, Change Other Cells According to Content

I'm trying to make a revision timetable for myself on Excel.
Let's say I'm doing four exams, A to D. Each exam has a certain number of "practice papers" that I have to do. Below is a demonstration table on Excel:
ExamName NoOfPapers
ExamA 4
ExamB 5
ExamC 7
ExamD 1
There is another table, with two columns: MonthDate and the paper I want to practice on that da. So,
May Paper?
1
2
.
.
.
29
I want to make it work so that if I put ExamA in the field under Paper?, it would automatically deduct 1 from the NoOfPapers of ExamA, to make it 3, so I make sure I'm not repeating the paper too many times.
If I only had 17 papers, it would have been easy to do it manually. But unfortunately I have 99 papers to do (exactly 99 :P).
How can I implement this on a cell as an IF statement (or any other possible way) on Microsoft Office Excel?
Thank you! :)
change the title of the column "NoOfPapers" to "OriginalNoOfPapers". Then create a column next to it called "NoOfPapersRemaining".
Assuming the cell with "ExamName" is A1, use the following formula in C2: =B2 - COUNTIF(Z:Z, A2)
(this also assumes that the column called "Paper?" is in column Z... in real life change it to the correct column on your spreadsheet.
I made four columns in row 1, Exam Name, Exam Total, Completed,Remaining. The completed column has the function
=Countif(B:B,A:A)
in roww 2, 3, 4, 5. The remaining columns are
D2="SUM(B2-C2)"
D3="SUM(B3,C3)"
D4="SUM(D4,C4)"
D5="SUM(D5,C5)"
In row 7 I have three columns, Date Complete, Exam Name, Paper. Exam Name must = The exact same as Cell A2:A5. All you would need is to enter the date and the exam name and it will show the total papers done and the remaining.
This can be better but does what I believe you asked. For instance, use of conditional formatting. If there is a deadline, add a column for the date and use conditional formatting to display an approaching deadline. Freeze row 7 to see remaining after entering a lot of dates in cell A8.
Hope this helps. I'm not a pro but like learning more about Excel.

Need help with formula on Excel

UPDATE 1:
This is what I am trying to do.
B1, B2, and B3 represent 3 containers
Period could be anything, days, weeks, months years, so Period 1, can mean day 1, or week 1, or month 1 or year one.
In period 1, I start off with the value 100. 60% of 100 always gets added to B1 (container 1), and 40% of 100 always gets added to B2 (container 2). B3 (container 3 does not get a percentage of 100. This happens on every period.
After the first period, i.e. period 2, B1, B2, and B3 all get 10% of the value of the previous B2 values divided by 3. So each container gets 1.33 in this example. However, B1 also gets another 60% of 100 added to it making the total 61.33 and B2 gets another 40% of 100 added to it making the total 41.33.
In the next period, period 3, again 10% of the values from B2 above period 3 divided by 3, i.e. ((40+41.33)*0.10)/3 gets added to all cells in period 3, then for B1, add another 60% of 100, and B2 get another 40% of 100.
ORIGINAL QUESITON:
I have the following spreadsheet which uses some basic formulas.
https://spreadsheets.google.com/spreadsheet/ccc?key=0Al-CN3-vjUYvdEdNMU4zN3FTNF9VZlMzZXBTcjh0Mnc&hl=en_US#gid=0
As you can see this goes from period 1 to 12. Is it possible to create a formula for columns B1, B2, and B3 to get the values based on the period? So, for example, if the formula was working, I would be able to simply type in 5 to get:
B1 = 65.61
B2 = 45.61
B3 = 5.61
Used = 500.00
If I type in 100 as the period, it should return the correct values, instead of creating 100 rows with the appropriate formulas per cell, which would take ages to do.
Does anyone know how to create the required formulas?
As shown online in your spreadsheet, you can use SUMIF:
For B1:
=SUMIF(C2:C13;A4;D2:D13)
And so on for B2, B3 and Used.
EDIT
I solved your issue on another Sheet of your Google Doc.
Needed some maths to found out which kind of sequence this was in order to sum up each element to the n-th one.
This was done for column E (meanly title B2):
=$A$2*$I$8*POWER($I$2/3+1;C2-1)
And then adapted to fit B1, B3 and Used, wasn't that easy...
For Ease Why dont you convert
=(((E2+E3+E4+E5+E6+E7+E8+E9+E10+E11+E12)*I2)/3)+(A2*I5)
to
=((SUM(E2:E12)*I2)/3)+(A2*I5)
Before all this math stuff isn't my best Art, but I figure out the answer anyways
Well, even when you can macro your function, some understanding of the formulae can help to a simpler answer:
First, the key column is B, if you analize his result you will identify this as a ''series'' (the math stuff, link to wikipedia here), checking of the results are calculated yield the followin table:
please, don't force to explain, because isn't my best area of expertise, but this is the solution (use a scientific calculator or mathematica to check this out), using this formulae you getthe value of the B column.
So, Column A and C, how we get it? A quick inspection show the following:
A=B+20
C=B-40
I hope this solves your question
Best Regards
Alen

Resources