Let's say I have a table of First/Last names and Salaries.I want to compute, for every last name, the sum of the salaries of people with that name.
I know how to do that for each name individually using SUMIF, but I was wondering if there is a quick function to produce a table of Last names and Salary sums?
Another option would be using a pivot table.
On the insert tab, select pivot table
Use your existing table as the data
In the fields select the Last Name and Salary columns
Let's support you have the salary sheet in sheet1 as below,
copy column last name value to sheet2.column A, remove duplicate, add a new column as Salary Sum in column B, input a formula as =SUMIF(Sheet1!B:B,Sheet2!A2,Sheet1!C:C) and drop down to all rows, then you can got a salary sum table as below,
of course, if the first name/last name is dynamic and unexpected, it would doesn't work. you can drop a button and bind a VBA code to handle it.
You could use this ARRAY FORMULA: CTRL + SHIFT + ENTER
=IFERROR(INDEX($A$2:$A$7,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$7),0)),"")
For summing up the corresponding values just use
=SUMIFS($B$2:$B$7,$A$2:$A$7,D2)
Related
I have a workbook which I insert a column in the Column H field on a daily basis. The data inserted is for records of the previous day.
I know by defining a formula in "Name Manager" I can add more columns and my formula will be static.
Example: I sum all data points for the month.
Formula_1 = " =SUM('Sheet 1'!H$6:$AK$6) "
When I add a new column in Column H then my formula includes this newly created column and shifts the second part of the reference to
$A$L6.
I have a Sparkline to show trends of my data. Every time I enter a new column I have to reconfigure the Sparkline "Data Range" to include my new column in the Column H field.
Is there a way I can have my Sparkline include my newly created column and shift my formula one cell to the right?
Yes. By putting your data in a table it automatically recalculates and readjusts whenever you add or remove a column or row.
As a table your data looks like this:
Then when I add a column and insert numbers, the sum column moves to E column and the function becomes =SUM(A2:D2)
Hope this helps.
Can you help me to solve this problem?
I have two row with different value each row like this:
I want to count how many city with name london but only count if the Name if different, so from the table above the result count is only 2 london.
You can use a pivot table as a step to help:
Select the data and set up the pivot table:
Change the design of the table to set:
a. Report layout to tabular form
b. Report layout to repeat all item labels
c. Subtotals - do not show them
then the pivot table should be like this:
Finally, you can use COUNTIF. In my example, I have put the city name in G2 and referencing it in the formula:
=COUNTIF(D:D,G2)
You first need to group both columns
=COUNTIF(UNIQUE(A2:B14),"london")
COUNTIF count cells based on one criteria
I have a dataset on an Excel table in which each line has an Id and several other columns.
in some others sheets I need to select some columns depending on the given id.
I am using Excel 2016, so I've tried the "dget" function but it seems not to be the best solution.
For the dataset it's close to this:
id Name birth date gendre
1 Sara 10/05/1997 F
2 Edward 01/08/1994 M
3 Anna 06/10/1993 F
and for getting data I use
=DGET(Table1[#All];Table2[[#Headers];[Name]];A1:A2)
in each column (A1:A2 here is for id and 2)
id Name salary
2 Edward 5000
and then I add some new columns that I don't want them to be in the first dataset.
This solution works only for the first row since it requires a the Criteria (last field in DGET function) to be a range, the official definition:
Criteria Required. The range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Starting from the second row the Criteria is not a range anymore it is like "A1;A3" (for the 1st row "A1:A2")
Is there any other solution or alternative to do so?
Select a cell in the Table, click Insert>PivotTable, then drag the ID, Name, BirthDate, and Gender fields into the ROWS area. Then add a Slicer on ID, Name, and Salary by clicking in the PivotTable and selecting Insert Slicer. Then choose the ID/Name/Salary values you want. To make multiple selections, hold down Ctrl or click the MultiSelect button of the Slicer.
Trying to write a formula for Excel, Using 2 worksheets. to classify the invoices
Worksheet 1 has Group Name and Group ID
Worksheet 2 has Group Name, invoice amount,invoice number
Trying to get the Group ID to worksheet 2, keeping in mind a ID can be use multiple times
Using formula below but the IDs I'm getting back aren't matching
=LOOKUP(F2,GROUP!C:C,ID!B:B)
Any help would be appreciated
Assuming GroupName is column 1 of Worksheet2 and that GroupName and ID are in columns A and B, respectively in Worksheet1
Place this formula in B1 of Worksheet2:
=vlookup(A1,Worksheet1!A:B,2,0)
Update all cell references and placements as they match your actual sheet data.
With vlookup you have to be sure that your data is first sorted, otherwise the algorithm tends to fail.
A better alternative, in my experience, is to do something like the following. I am assuming that Worksheet 1 has Group Name in Column A and Group ID in column B, and that Worksheet 2 has Group Name in column A. This formula would go in worksheet 2, in a blank column starting in row 2:
=index(Worksheet1!B:B, match(A2, Worksheet1!A:A, 0))
If you fill that equation all the way down, then it will perform the equivalent to a vlookup but without the need to sort your data first.
In Worksheet2:
=Vlookup(F2,Worksheet1!B:C,2,False)
But it would be better to size the table exactly and not refer to the whole column, like:
=Vlookup(F2,Worksheet1!B1:C200,2,False)
I have a data table with 8 columns and i want to know if anyone can help me come up with a formula to get the name in the first column if i enter a value into the columns (3,4,5,6,7,8).
I want the name from the first column to appear in another table on another sheet where only names appear where data is in the columns (3,4,5,6,7 & 8)
Try this:
=IF(OR(Sheet1!C2<>"";Sheet1!D2<>"";Sheet1!E2<>"";Sheet1!F2<>"";Sheet1!G2<>"";Sheet1!H2<>"");Sheet1!A2;"")
You can use C1 = 1 .... if you prefer.
And C1,D1,E1... have to be replaced with your columns.
Also Sheet1 have to replaced with your sheet name
I would use a Pivot tables.
First create a new column in the existing table:
If you only having positive values then it is:
=sum(C2:H2)
If you have zero and negative values as well it would be like this:
=IF(COUNTBLANK(C2:H2)=6;0;1)
Then make a pivot table with the "TO/TA name" in the Row Labels and the new column in Report filter - where you then removes the "0".