How many times number occurs in other numbers - excel

I have different values of meal vouchers.
I want to enter the payout value and get exactly how many vouchers of each, the person is going to get.
Here is a picture for better understanding.
In the picture there is this example. A person gets a payout of 64€ and the result is how many of 4.2 , 4 , 3.8..... vouchers he has to get.
Image of Excel table

These scenarios are very difficult to solve with formulas, but if you don't require the exact amount as the total of the vouchers, but a close approximate, then try this:
B4 =IF($L4>B$3,INT($L4/B$3),0)
C4 =IF($L4-SUMPRODUCT(($B4:B4)*($B$3:B$3))<C$3,0,INT(($L4-SUMPRODUCT(($B4:B4)*($B$3:B$3)))/C$3))
Copy C4 across and then copy B to K down.
With this approach the highest voucher value will be considered first. In some cases this may not be the best approach. There are numbers where it would be better to ignore the higher value vouchers and hand out more smaller value vouchers to get closest to the total value. For example, if the payout is $7, it would be best to give out two 3.5 vouchers. The formula will use one $4.2 voucher and one $2 voucher, getting close to $7 total, but not quite there.
The problem as presented requires multiple iterations over the data set, but with formulas this is not possible to do, AFAIK.
Click to open the file. It will open in Excel online and you can download a copy.

Related

How to count pairs of cells in alternate rows

I am preparing a weekly time-table for my school which looks like the following
The even rows contains course names, whereas the odd rows contain the teacher initials. Observe that a same paper is taken by more than one teacher (e.g., C10 C11 and G10 G11). I need to count the total number of classes per course per teacher in a week. Please help me to achieve that.
My efforts so far have been very inefficient.
I calculated the formula in B71 for each row in the entire time-table and added all the quantities in B70. However I need to have a comprehensive list of all courses with divisions for all teachers. I am not being able to generate that.
Thanks in advance.
You where pretty close in your attempt. You could use the following in B70 and fill down and to the right:
=COUNTIFS($C$10:$P$67,$A70,$C$11:$P$68,B$69)

Of the 10 individuals with the highest income, how many are married males?

Question --> Of the 10 individuals with the highest income, how many are married males?
I want to achieve the same in a single function.
Below is a database.
enter image description here
First I fetched data with Large and the applied vlookup and the used counifs to get the count.
enter image description here
enter image description here
You are close.
Why are you using IFERROR? Are there errors in the data or something else?
In the formula below, I used a Table and Structured references. An advantage is that the range references will automatically adjust. You can switch to normal addressing if you prefer.
I would use:
=COUNTIFS(myTable[Income],">="&LARGE(myTable[Income],10),myTable[Sex],"M",myTable[Married],"Yes")
With regard to your formula, you would think you could just SUM the results. Unfortunately, for any instance where there are duplicates (2 married men with same income in the top 10), your formula would return a 2 and not a 1 and the SUM would therefore be incorrect.
You can avoid that, with your approach, by converting any non-zero into a 1:
=SUM(--ISNUMBER(1/(COUNTIFS(myTable[Income],LARGE(myTable[Income],SEQUENCE(10)),myTable[Sex],"M",myTable[Married],"Yes"))))
However, I think my approach is simpler.

Microsoft Excel 2007 Always round up even if the decimal is under 0.5

So I'm creating a spreadsheet that determines the cost of materials and the number of each material needed in order to complete a desire project using input from myself. Right now the desired project is a wall that is 250x9 that requires replace all the 4x8 sheets of wood with OSB and install Vinyl Siding. The issue I'm running into is I cannot get it to always round up. By that I mean even if the value is 1.1 it should round up. In this specific case I am buying nails for my nail gun in a box of 2,000 and each sheet of OSB will have 32 nails in it. If 250x9 area requires 70.3125 sheets of OSB it means I still have to buy 71 sheets of OSB. If that OSB is 71 sheets then it require that I have 2272 Nails then the result is I need 1.125 Boxes of nails. However I can't seem to get it to show this as 2 boxes because again I still need to purchase more than one box to complete the project. So with that being said if I take the number of OSB needed 70.3125 and I place it in a formula with a roundup function it still rounds down (gives me a headache that there is a roundup and a rounddown function and it will still round down on me. Perhaps it is the way I am using it in the formula that is incorrect, I'm not sure. So let me translate the formula's used and you can let me know if I'm doing something wrong or if there is a function or set of functions that I can use to solve this issue.
=SUM(((B30*C30)+(B35*C35)+(E30*F30)+(H30*I30))/(E9*G9))
This says that if I added Wall1 L*W with Wall2 L*W with Wall3 L*W with Wall4 L*W and divide it by OSB H*W I get the number of sheets needed. Which in this case is 2250/32 basically. But its programmed in a manner that I can input the information for individual walls to different area's and get it to spit out the total SqFt for each wall and give an individual breakdown per wall of material needed with cost associated per sq ft of material bleh bleh bleh. The point is I take the result that is the 70.3125 and I move it to a different workbook and I say "Sheets OSB Needed" and in that box I have
=ROUNDUP(Sheet1!A9,1)
Whereas I'm asking it to roundup A9 which is the result of the above formula by intervals of 1. But the output is still 70 instead of 71. and much the same case with the nails needed. Which can be calculated in a few different manners but regardless the amount of nails needed divided by 2000 would output the decimal answer which yields a value of less than 1.5 and it too provides me with a value of 1 instead of 2 with much the same formula. I could achieve my desired result I suppose with Trunc and Mod functions collaborating using multiple cells to output the different portions of the data. But is there a way to do this that doesn't involve so many cells being used up?
C7
=Trunc(A9)
Removes Decimal from 70.3125
C8
=MOD(A9)
Outputs decimals from 70.3125
C9
=IF(C8<1,"1",C8)
If Decimals are < a whole number make it a whole number
C3
=SUM(C7+C9)
Add the whole number to the Trunc Number to get value desired.
Which I'm already seeing an issue with this if there is no decimals in the sheets needed then wouldn't it always add one because the decimal place would be 0? How can I handle this issue? Isn't there an easier way to do this or a way to code it so that its all nested into one calculation or at least mostly all into one calculation without making a circular reference of some sort?
You need to change the second parameter to a 0 ROUNDUP(70.3125, 1) is 70.3 the 3 must be getting dropped elsewhere or lost in formatting.
ROUNDUP(70.3125, 0) will give 71.
The second parameter of round up is the decimal place. So to round to integers it should be 0 not 1

excel rows,find if include,low and high

it seems that i cant post my picture.here is my link to it:
picture: http://s18.postimg.org/nfv997rvd/head.png
Hello Stackoverflow.
I have some things I wondering about here. I'll try to take it step by step:
It is marked in orange color:
As mentioned in the example in the picture it says "headphones". I would like it to search through all the lines in column A, to find something that has that name in it, then it should count the number of people, and come out with the number (in how many)
the "middle price" I want it to take the price of B (depending on where it found it called headphones) and take the average price of it.
In secured, as I would like it to count how many of them (from the number, or from the beginning) that have "secured" as "no" and "yes."
would like to use this on several things.
pink:
where would I find the average price of all the goods, and what the name of the particular item is.
same with the highest and lowest price.
How can I do this?
to find out how many Headphones:
=COUNTIF(A:A,"*Headphones*")
Note the *'s around the word so it can be found anywhere in the text to make a match.
For middle price there are 2 options, depending on how you want to define the average.
If it's a straight average:
=AVERAGEIF(A:A,"*Headphones*",B:B)
If you want the median, then you will have a slightly more complex formula with
=MEDIAN(IF(A1:A100="*Headphones",B1:B100))
and entered as an array formula with Ctrl+Shift+Enter
maximums and minimums can also be found with the same type of array formula
=MAX(IF(A1:A100="*Headphones",B1:B100))
=MIN(IF(A1:A100="*Headphones",B1:B100))
Excel also has COUNTIFS for multiple criteria:
Secure/Not Secure Headphones:
=COUNTIFS(A:A,"*Headphones*",E:E,"Ja")
=COUNTIFS(A:A,"*Headphones*",E:E,"Nei")

How can I implement 'balanced' error spreading functionality in Excel?

I have a requirement in Excel to spread small; i.e. pennies, monetry rounding errors fairly across the members of my club.
The error arises when I deduct money from members; e.g. £30 divided between 21 members is £1.428571... requiring £1.43 to be deducted from each member, totalling £30.03, in order to hit the £30 target.
The approach that I want to take, continuing the above example, is to deduct £1.42 from each member, totalling £29.82, and then deduct the remaining £0.18 using an error spreading technique to randomly take an extra penny from 18 of the 21 members.
This immediately made me think of Reservoir Sampling, and I used the information here: Random selection,
to construct the test Excel spreadsheet here: https://www.dropbox.com/s/snbkldt6e8qkcco/ErrorSpreading.xls, on Dropbox, for you guys to play with...
The problem I have is that each row of this spreadsheet calculates the error distribution indepentently of every other row, and this causes some members to contribute more than their fair share of extra pennies.
What I am looking for is a modification to the Resevoir Sampling technique, or another balanced / 2 dimensional error spreading methodology that I'm not aware of, that will minimise the overall error between members across many 'error spreading' rows.
I think this is one of those challenging problems that has a huge number of other uses, so I'm hoping you geniuses have some good ideas!
Thanks for any insight you can share :)
Will
I found a solution. Not very elegant, through.
You have to use two matrix. In the first you get completely random number, chosen with =RANDOM() and in the second you choose the n greater value
Say that in F30 you have the first
=RANDOM()
cell.
(I have experimented with your sheet.)
Just copy a column of n (in your sheet 8) in column A)
In cell F52 you put:
=IF(RANK(F30,$F30:$Z30)<=$A52, 1, 0)
Until now, if you drag left and down the formulas, you have the same situation that is in your sheet (only less elegant und efficient).
But starting from the second row of random number you could compensate for the penny esbursed.
In cell F31 you put:
=RANDOM()-SUM(F$52:F52)*0.5
(pay attention to the $, each random number should have a correction basated on penny already spent.)
If the $ are ok you should be OK dragging formulas left and down. You could also parametrize the 0.5 and experiment with other values. With 0,5 I have a error factor (the equivalent of your cell AB24) between 1 and 2

Resources