I have an excel sheet of data. I have to prepare report based on gender and age wise distribution count. The excel sheet has three columns NAME, GENDER, AGE. I have to get the count of Male, Female Population according to age distribution of
Under 10
10 yrs - 18 yrs
19 yrs - 49 yrs
50 yrs - 59 yrs
Above 60 yrs
How can I get the count in excel? I have no idea of excel programming. Attached herewith is only sample data I have thousands of rows of actual data. I have no idea how to do such analysis in excel. Please help!!!
I've attached the data as well as required count format in the image.
#Ted Williams, I didn't find a solution as you suggested. I failed to get rows or columns for each of the five age groups into the pivot table. So, I guess the task you set for OP was too difficult. Instead of a pivot table I used the formula below to assign each age to one of the five age groups.
[D2] =MATCH(C2,{0,10,19,50,60},1)
Next, I built a copy of your "Reporting Format" table in A17:K18 - five age groups with 2 columns each, just as you published it. Then I entered the next formula in B20 and copied all the way across to K20.
[B20] =COUNTIFS($B$3:$B$15,B$18,$D$3:$D$15,INT(COLUMN()/2))
Column D of the table this formula references contains the age groups already mentioned above and column B contains the gender. This table was copied form the data table you posted, assuming that the names are in column A.
INT(COLUMN()/2) is a counter which is built on the the original formula being in column B. COLUMN() returns the number of the column in which the formula resides. If the original is in column B it will return 2, 3, 4, 5, 6, 7, 8, 9, 10 as it is copied to B20:K20. Dividing this number into 2 will create a fraction which we can't use to address column numbers but the INT() function will round that fraction down. So, the result of =INT(COLUMN()/2) will be 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, exactly the age groups we have in column D and, of course (hopefully) the age group captions we have in row 17. The point of this explanation is that this function may return the wrong result if the original is not in column B. Adjust it like this, =INT((COLUMN()+x)/2) (where x is likely to be a negative number) and test it by itself in the columns in question to ensure that it returns the numbers 1 to 5, each number twice.
Here's what I meant:
Binned Age is from the table in H:I using index/match formula.
Pivot table uses BinnedAge then Gender for columns and count of name for values
If you want the bins sorted in a different order in the pivot table then see:
https://www.excel-university.com/sort-a-pivottable-with-a-custom-list/
Related
Weights
I have built a tab in an Excel spreadsheet that uses base data from 6 columns and then formulas in 9 additional columns that determine the final result in another column, which then gets copied into another cell on another tab (see 'weights' picture at top of this post):
The base data is in 6 columns A-F and has 729 rows - each column has a certain weight (30%, 20%, 20%, 10%, 15%, 5%). Each cell is either 1, 2, 3, 4, 5, N/A, or blank. The goal is to look for N/A or blanks and then redistribute the weight for those categories to the remaining non-N/A and non-blank categories, so if the 20% column was N/A and the other 5 columns were 1, 2, 3, 4, or 5, I would add 4% to each of the 5 scored categories to calculate the final score. Everything works great but I am interested in doing everything in one column after the 6 base columns. I start by converting N/A to 0 and then handle things in multiple columns by doing this:
In Column G, I get the total weight of the columns with N/A or 0:
=SUMIF(A2:F2,0,$A$729:$F$729)
Then in Column H, I get the number of columns that the weight percentage in Column G will get distributed to:
=COUNTIF(A2:F2,">0")
Then in Column I, I calculate the percentage to be added to the remaining columns:
=IF(H2=0,0,SUM(G2/H2))
Then in Columns J-O, I calculate the new weight percentages for each weight (the original weight percentages are in cells H2-H7 on a different tab called 'Controls':
=SUM(Controls!$H$2+$I2) is for Column J, =SUM(Controls!$H$3+$I2) is for Column K, etc.
Then finally I calculate the 'new' score with the 'new' weights. If there were no N/A or 0's, it keeps the original overall score and if not it multiples the score in a cell (1,2,3,4,5) by the new weight and adds the six totals together:
=IF(H2=6,Q2,SUM(A2J2)+(B2K2)+(C2L2)+(D2M2)+(E2N2)+(F2O2))
It all works great, but how can do what I'm doing in 10 columns with just one statement in one cell? I'm assuming there are lots of elegant references and nesting required but I'm not sure how to do it.
Thanks in advance!
You can do this step by step:
e.g.
cell (G2) =SUMIF(A2:F2,0,$A$729:$F$729)
cell (H2) = COUNTIF(A2:F2,">0")
cell (I2) =IF(H2=0,0,SUM(G2/H2))
In cell I2 replace the cell references of G2 and H2 with the formula expression of the respective cells.
More elegant with LET:
https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999
If I have table 1 with OrderIDs and CallIDs and table 2 with CallIDs (that are referenced in table 1) and callDates, how can I find the number of orders within a given date range?
I believe what I need to do is get the calls that are within a date range in table 2, then check if the CallIDs exist in table 1, then get the count of the result. I just do not know how to put it all together in a formula. For instance in the picture, the number of orders in February should be 3.
=SUM(COUNTIFS(E2:E15,">="&DATE(2022,2,1),E2:E15,"<"&DATE(2022,3,1),D2:D15,B2:B8))
COUNTIFS creates an array of 0's and 1's (respectively FALSE and TRUE) for the date range in column E containing values greater than or equal to February 1st and smaller than March 1st and where the call number from column D is found in column B.
SUM adds up the 1's and 0's resulting in your count of matches in that range.
I'm using SUMIFS to calculate sales revenue of product X over a period of time. The problem is that all the sum range and the criteria ranges are dynamic since sales reps will add more rows to record new sales everyday. My formula looks like this:
=SUMIFS(Revenue!I5:I24,Revenue!F5:F24,"Product X",Revenue!B5:B24,">="&B3,Revenue!B5:B24,"<="&C3)
The starting row is row 5, and the last row that currently has data is row 24.
Revenue is the worksheet that contains the data. In this worksheet, column I is the revenue, column F is the product name, column B is the date that the revenue is recorded. B3 and C3 are the start and end date of the period.
When a sales rep records a new revenue, the last row that has data will become row 25, so my formula won't count it in. I tried to replaced 24 with 1000 hoping that it would count when new data was added beneath, but it returned #VALUE.
What should I do?
Thank you
Declare 3 dynamic ranges and use their names in your formula.
=IFERROR(SUMIFS(revenueI,revenueF,"Product X",revenueB,">="&B3,revenueB,"<="&C3),"")
Adding the names: Press Ctrl+F3 to open the name manager and then enter the 3 names
Name: revenueB
RefersTo=
OFFSET(Revenue!$B$5,0,0,COUNTA(Revenue!$B$5:$B$1048576),1)
Name: revenueF
RefersTo=
=OFFSET(Revenue!$F$5,0,0,COUNTA(Revenue!$F$5:$F$1048576),1)
Name: revenueI
RefersTo=
=OFFSET(Revenue!$I$5,0,0,COUNTA(Revenue!$I$5:$I$1048576),1)
1048576 is for the max number of rows in more recent versions of Excel. Adjust to the total number of rows for your Excel version.
Wrap in an IFERROR in case of errors e.g. if named ranges are off different length.
I have a spreadsheet that contains users in each column. Below each user lists groups that they are in.
I want to highlight values that are not in every column.
If a user is part of a group that everyone is a part of, that group would not be highlighted.
If there was even one person who wasn't part of that group as well, that group would be highlighted.
Example.
Say there are 3 columns: A, B, C.
Column A has values 1, 2, 3, 4, 5 listed below it. Each number in a different row
Column B has values 1, 2 ,4, 5 listed below it.
Column C has values 1, 2, 4, 6, 7 listed below it.
In this example
In Column A, 3 and 5 would be highlighted.
In Column B, 5 would be highlighted.
In Column C, 6 and 7 would be highlighted.
Because each of those numbers are not listed every column.
So, you can do this using Conditional Formatting using the following logic:
Just for the sake of example, suppose your data is in the range A1:H20 with, as you said, each column being a new user and the first row A1:H1 being user names.
What this tells us:
COUNTA($A$1:$H$1) = Number of users
COUNTIF($A$1:$H$20,A2) = Number of times the value in A2 appears in your dataset
Therefore if COUNTIF($A$1:$H$20,A2) < COUNTA($A$1:$H$1), that means the value in A2 does not appear in each column (otherwise they woud be equal). (Also note that this is based on the assumption that you can't have a value appearing twice in a given column!).
At this point, it's a simple conditional formula.
Hope this explains it well enough.
I have a list of Excel data set up like this.
Items
1, 11, 3
4, 5, 6
7, 9, 12
15, 13, 4
7, 8, 9, 10, 1
14
1, 3, 7, 9
I want to make a count of each occurring number, so that I end up with a result like this:
Items A2 Column
1 2
2 0
3 2
4 2
5 1
And so on. Are there any formulas I can use to count the frequency of each number?
I've tried using the COUNTIF function, but the formula will often come out as 0 because it can't read each number separately in the cells. Using a Pivot Table created the same results as well.
First split those integer values into their own cell:
Data>>TextToColumns>>Delimited>>Comma>>OK
Second set up a table where 1 through whatever is listed in the rows, then you can use countif() to get the counts.
=COUNTIF($A$2:$E$8,A14)
Where $A$2:$E$8 is the group of cells that was created with Text To Columns, and A14 is the first cell in your list of of 1 to whatever. Copy that down to each row in your list of 1 to whatever and you'll have what you are looking for.
Assumptions Made:
-Your data is all in column A but in multiple rows.
-Each cell in column A has one or more comma separated data sets (as shown above)
In Column D1 Place a Title "Items" and enter your item numbers in column D starting with D2 and continuing.
In Column E use the following Formula
=SUM(COUNTIF($A:$A,D2&","),COUNTIF($A:$A," "&D2),COUNTIF($A:$A,", "&D2 &","),COUNTIF($A:$A,D2))
Explanation:
COUNTIF($A:$A,D2&",*") - finds entries for the specified item that are the first item in a data set with more than one item listed
COUNTIF($A:$A,"* "&D2) - finds entries for the specified item that are the the last item in a data set with more than one item listed
COUNTIF($A:$A,", "&D2 &",") - finds entries for the specified item that are neither the first, nor the last item in a data set with more than one item listed
COUNTIF($A:$A,D2) = Finds entries for a specified item where the data set only contains one item.