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

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.

Related

How to resolve Excel IF AND question query formula

Need help with a Excel formula.
I have two sets of data in two tables, with the same number of columns and rows.
One table has data for male, the other one for female.
Each table has a common definer (age). All the other data are different. All data are in numbers. Some are negative.
I aim to use a single cell to get a result coefficient used by a specific equation, and I need to channel the input data by two criteria. One is gender, the other one is age. I am trying the IF AND formula, but it is not working.
Here is an example.
age (D2) coefficient (D2-D4)
Table Female.
18-30 yrs 25
30-60 yrs 35
60-70 yrs 41
So here is the data to process:
D1 F
D2 29
D3 115
(MEANING Gender - female; age 29; weight 115 pounds)
I was trying the IF AND formula
=IF(AND(D1="F";D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4)))
Now, this works fine when I only calculate the female data, but I can't seem the find the way to include the formula to choose from the MALE table, if the subject is male ("M").
Any help or clues on how to resolve this?
Welcome to stackoverflow. It would be easy to help you if you paste a screenshot of your table etc as it would make us understand your problem clearly.
Anyway, two solution advice from me:
1- you can use nested if operators but not like yours. Before expressing conditions with and operator, add another if to start processing data related to females. Like this: =IF(D1="F";IF(AND(D2>17;D2<30);(D3+H2);IF(AND(D2>=30;D2<60);(D3+H4))).
After processing females, add the same formula strings this time for males. This will solve your puzzle I guess.
2- my second advice would be creating a user-defined function. I often create a user-defined function if my formula gets too long and become hard to read. I strongly recommend you to search for this as it will make you better-understand the logics in excel functions and make you equipped against your puzzles in future.

I need help to make data coherent in excel

I have database where a some data is inconsistent. This database summarize different variables among 10.000 industrial firms (e.g. number of employees, energy consumption, value of assets, among another 83 variables) over 10 years. My issue is that the firms change over time the International Standard Industrial Classification (ISIC) code and I need to put the same code to the firm in order to make a coherent analysis.
In the image you can see how the firm 987653 has two different ISIC code (textiles and Food manufacturing)
It is possible to have some help to create a formula to put a new ISIC code based on the most repeated value (in the example of the firm 987653 will be food manufacturing).
You can try following array formula to find most used code:
{=INDEX($D$2:$D$23,MODE(IF($A$2:$A$23=A2,MATCH($D$2:$D$23,$D$2:$D$23,0))))}
Array formula after editing is confirmed by pressing ctrl + shift + enter
A simple VLOOKUP should do what you want, if you can live with using the first ISIC for the company. eg:
F2: =VLOOKUP(B2,$B$1:$E$10,4,FALSE)

How many times number occurs in other numbers

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.

AverageIf and Multiple data strings

I'm involved with a youth football tournament on the referee side, with assessing/coaching the referees. I've just taken over doing the data entry for the referees assessment scores which we then use to determine who gets finals etc and am looking to extract more usable information from the data to help us identify trends.
I've got (up to) 200 referees, each receiving from none to two assessment scores each day for 5 days. The scores are entered as both the raw mark and the weighted mark based on match difficulty (along with a host of other data about the match that isn't relevant to this issue.
I can extract the average mark (raw and weighted) across all referees without issues and have done so using the below formula, which is the raw average mark:
=AVERAGE(Working!AK4:AK200,Working!BK4:BK200,Working!CL4:CL200,Working!DL4:DL200,Working!EM4:EM200,Working!FM4:FM200,Working!GN4:GN200,Working!HN4:HN200,Working!IO4:IO200,Working!JO4:JO200)
But I also want to extract the average mark (raw and weighted) across two subsets - Academy and non academy referees, to help plot trends and determine where resources need to be utilised.
I've attempted to use an AVERAGEIF formula, but am getting a #VALUE! return. This is the formula that I've attempted to use to return the average raw mark for those referees in the academy:
=AVERAGEIF(Working!G4:G200,Working!G4:G200="Yes",(Working!AK4:AK200,Working!BK4:BK200,Working!CL4:CL200,Working!DL4:DL200,Working!EM4:EM200,Working!FM4:FM200,Working!GN4:GN200,Working!HN4:HN200,Working!IO4:IO200,Working!JO4:JO200))
If I do the same formula as above, but without the brackets around the [average_range], I get a 'you've used too many arguments, and it highlights BK200.
From what I've been able to find so far online, it seems that the formula I'm trying to use would only work if ALL the cells in (Working!G4:G200) returned "Yes". However if there are only 50 academy referees as indicated by "Yes" in G column, then I want those specific scores to be averaged, and the inverse for the non-academy referees.
I thought about having another sheet, which would simply contain populate from Column G (a simple =G4 and then populated down to =G200 next to all of the scores), consolidated into a block of raw marks columned under Assessment 1, 2, 3, 4.... and then the same for all of the weighted marks which would populate from the equivalent cell on the working sheet, but there's a lot of filtering, and re-sorting that goes on on the working sheet, and I'm not 100% certain that that wouldn't cause issues.
Any feedback on how to work through this problem, so that I can display the overall average mark for academy and non-academy referees in both raw and weighted form would be much appreciated, and I apologize if this post is rather convoluted.
I don't think there is a neat solution if the scores are in several columns which are not consecutive.
My suggestion is:-
(1) Work out the sum for each column separately and total them up
(2) Work out the count for each column separately and total them up
(3) Divide Sum by Count to get Average.
In my small example below with 3 referees and 3 columns:-
(1) In K2:-
=SUMIF(H2:H4,"Yes",B2:B4)+SUMIF(H2:H4,"Yes",D2:D4)+SUMIF(H2:H4,"Yes",F2:F4)
(2) In K3:-
=COUNTIFS(B2:B4,">=0",H2:H4,"Yes")+COUNTIFS(D2:D4,">=0",H2:H4,"Yes")+COUNTIFS(F2:F4,">=0",H2:H4,"Yes")
(3) In K4:
=K2/K3
This would include any zero scores (if this is possible) but exclude any blanks.
You can then scale it up to your data.
Beyond this, you would have to change the data structure either
(1) Add a row to label the columns that you want to average e.g.
Score 1 Score 2 Score 3
3 0 3
so you could pick up only the columns labelled 3 say
Here's how it would be in my small example:-
In K3:-
=SUM((B$2:F$2=3)*($H3:$H5="Yes")*B3:F5)
Which is an array formula and must be entered with Ctrl-Shift-Enter
In K4:-
=SUM((B$2:F$2=3)*($H3:$H5="Yes")*(B3:F5<>""))
another array formula
In K5:-
=K3/K4
This is how the columns you want are labelled with a 3 in row 2, so it ignores the other columns:-
(2) Consolidate them into another sheet as you suggest.

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")

Resources