I have a set of data with multiple columns. I'm trying to transfer the data from columns to rows, but only for the unique members.
For instance, I would like the "Hours Worked" to populate under the correct month in the rows to the right based on unique "SSN"
I've tried =IF($P2=$C2,HLOOKUP(Q$1,$H:$H,MATCH(Q$1,$H:$H,0),FALSE),"")
Index/Match, etc but can't figure it out.
https://docs.google.com/spreadsheets/d/13jJJ0GXb6hFW7YEyyqrCn8cfotUeFurtm0U1EFj_kPY/edit?usp=sharing
Try the following formula in cell F2 and copy it over:
=SUMPRODUCT(--($E2=$A$2:$A$13),--(F$1=$C$2:$C$13),$B$2:$B$13)
The result of ($E2=$A$2:$A$13) is an array containing trues and falses, depending on whether the ID in column E is equal to the ID in column A. (F$1=$C$2:$C$13)does the same thing for the date. By adding -- in front of these arrays, we convert the trues and falses to ones and zeros, respectively. The third array contains the hours worked in each month. These three arrays are then multiplied (and summed up in case there were several entries for one ID in one month).
Related
I want to create a summary (sum or count) of a list of data based on two columns, showing all the unique items from the first column down the rows, and the unique items from the second columns across the columns, and the sum (or total) for each combination
I can do the sums with multiple formulae, but I'd like to try to do it in one
OK, so I already have an answer which takes just three formulae, one each for the list of unique row and column items, and one to create all the table counts (and sums are easy to do instead)
If my two columns I want to compare are A and B, and I want my crosstab to start in D1 (say)
This formula gives me a unique sorted list of items in column A, down the page
The filter is used to exclude blanks, otherwise Excel will add a 0 at the bottom
D2 = SORT(UNIQUE(FILTER(A:A,A:A<>"")))
This formula gives me the unique sorted items from the second column, transposed to go along the columns
E1 = TRANSPOSE(SORT(UNIQUE(FILTER(B:B,B:B<>""))))
Then this formula goes in E2
E2 = COUNTIFS(A:A,D2#,B:B,E1#)
As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)
I have seen questions on here that are similar but not the exact issue I am having. It is below and please forgive me if I don't explain this well.
I have 3 columns.
Column A is a list of file numbers in our system. This column contains many duplicates and is 172522 rows.
Column B is that same list of file numbers, but with the duplicates removed. This is 28858 rows.
Column C is a list of Reference numbers corresponds with Column B exactly, i.e. C2 is a reference number for B2 and so on
I need a query that pulls the reference number from C and places in it column D, for as many times as the file number occurs in Column A. So I get a list of duplicated filenos with their corresponding duplicated Reference numbers
Is this possible?
=VLOOKUP(A1,$B$1:$C$28858,2, False)
Vlookup takes a value and finds it in a "range" and then allows you to take another value in that range and return it. In this case, the 2nd column of range B,C. Though i believe the first column in the range is always the one it has to look through.
I have a design software which extracts data in to an Excel sheet format
The output is divided into 2 columns, each of these columns has more than 1000 rows.
To make use of this data I need to summarize it to a maximum of the 5 highest values from both of the 2 columns. Therefore, this doesn't mean that it's the maximum of one column and its corresponding value, but it may mean that the 2nd largest value of column 1 & the 4th largest value of column 2.
For example ( if we quoted some of the output data):
The values i should pick here are:
If there is any possible way to achieve that, it will be great
Thanks ..
example file: http://goo.gl/UIEFEv
example file 2: http://goo.gl/VSvuVf
Here's a formula solution. I used 20 rows and extracted the rows which contain the top 5 for each column - you can extend to as many rows as required.
With data in A1:B20 use this formula in D1 confirmed with CTRL+SHIFT+ENTER and copied across to E1 and down both columns:
=IFERROR(INDEX(A$1:A$20,SMALL(IF(($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)),ROW(A$1:A$20)-ROW(A$1)+1),ROWS(D$1:D1))),"")
Note: there are only eight rows extracted because some of the rows contain values in the top 5 for both columns. I added the highlighting in colums A and B to more clearly illustrate
see screenshot below
Edit:
From the comments below it seems that you want a combination of rows which contain the highest value for that column....and rows which contain the highest total for both columns.
In the original formula there are two conditions joined with "+", i.e.
($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)
The "+" gives you an "OR" type functionality, e.g. in this case rows are included if individual values are in the top 5 in that particular column. You can add other conditions, so if you want to also add any rows which are in the top 5 considering the total of both columns then you can add another "clause", i.e.
($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)+($A$1:$A$20+$B$1:$B$20>=LARGE($A$1:$A$20+$B$1:$B$20,5))
....and including that in the complete formula you get this version:
=IFERROR(INDEX(A$1:A$20,SMALL(IF(($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5))+($A$1:$A$20+$B$1:$B$20>=LARGE($A$1:$A$20+$B$1:$B$20,5)),ROW(A$1:A$20)-ROW(A$1)+1),ROWS(D$1:D1))),"")
You could refine that further by using combinations of + and * (for AND), e.g. for the new condition you might only want to include rows with a total in the top 5 if one of the single values is in the top 10 for that column...
Explanation:
The above part shows how you can use + for the OR conditions. In the formula if those conditions are TRUE then the IF function returns the "relative row number" of the range (using ROW(A$1:A$20)-ROW(A$1)+1).
SMALL function then extracts the kth smallest value, k being defined by ROWS(D$1:D1) which starts at 1 in D1 (or E1) and increments by 1 each row.
INDEX function then takes the actual value from that row.
When you run out of qualifying rows SMALL function will return a #NUM! error which IFERROR here converts to a blank
The question is a little unclear but if what you mean is to get the 5 highest values of Column A and their corresponding values in Column B then the five highest values in Column B and the corresponding values in Column A then the (non automated) solution is pretty simple.
Click on a cell with a header title in it.
Click on 'Data' in the top menu.
Click on 'Filter' in the 'Sort & Filter' section.
Click on the button on Column A - select 'Sort Largest to Smallest'
Grab the top five values from both columns then click on the button in column B and repeat.
Column A represents serial numbers of different parts, but these parts come from different suppliers so they have different prices. Column B holds the price for each part.
I need a macro that will essentially go down Column A, compare the column B price for duplicates, and return the min price for the part in column C.
Alternatively, you could:
Create a pivot table, selecting columns a and b as your source
Set serial number as a row field (drag it to the left of the table)
Set price as a data field (drag it to the middle)
Choose to display min of price rather than sum (the default)
Working out the formula was much more entertaining, though!
You can do this without even needing array formulas:
=SUMPRODUCT(($B$1:$B$5)*($B$1:$B$5=MIN($B$1:$B$5+(A1<>$A$1:$A$5)*MAX($B1:$B5))))
/SUMPRODUCT(1*($B$1:B$5=MIN($B$1:$B$5+(A1<>$A$1:$A$5)*MAX($B1:$B5))))
The important insight here is that you can do array operations inside a SUMPRODUCT, and inside functions inside a SUMPRODUCT. The first SUMPRODUCT gives the sum of all the prices that are equal to the minimum price for each component, and the second one gives the number of listings that have that price. Divide one by the other and you have the minimum price for each component!
First SUMPRODUCT:
($B$1:$B$5) is a column vector of your prices.
We're then creating another column vector whose entries will be coerced to 1 if the corresponding entry in $B$1:$B$5 is equal to MIN($B$1:$B$5+(A1<>$A$1:$A$5)*MAX($B$1:$B$5)) and zero otherwise.
The part inside the MIN function starts out as the original vector of prices, but if the serial number from each row of column a is not the same as the one in the current row, we add on the largest price from anywhere in column B to the current row in column B.
This prevents any parts with different serial numbers from being counted as having the minimum price while leaving all prices for the current part unchanged.
This means we've constructed a column vector where all the entries are either zero or equal to the lowest price for the component in the row of the cell in which the formula is entered.
The second SUMPRODUCT is similar to the first, except this time we just add up the number of times the condition is met without multiplying by the price.