Arrange excel columns based on first column - excel

Basically I have 2 columns of data in excel, A and B. Does anyone know how to arrange column A in descending order but also have the associated information in column B follow the data in column A.
Secondly, say I have two pieces of data in column A that have the same value, how can I order the information in descending order based on the values in column B in that case?

You mean something like this??

Related

Count values for each row with a unique ID

I have a bunch of rows in a table. Each row reflects an event in a patient. However, one patient can have experienced multiple events, so it's possible for there to be multiple rows with the same patient number. Now I'd like to count the amount of male patients in my database, without counting the ones that had multiple events multiple times. Each patient is identified by a unique patient ID that could be used for this.
This shouldn't be all that complicated if not for the fact that I'm using a table that also has several filters, so I need to use SUBTOTAL for any counting functions.
I literally have no idea where to start, so I can't really provide any code...
Any function that could point me in the right direction would be greatly appreciated.
Thanks for the help.
~Laurens
Use a Pivot Table to filter and count all your patients database. Select your data and select Insert -> Tables -> Pivot Tables. Put your filters at the Filter section of the table and the Patient ID in the Rows section. Then, you can use COUNT to get the number of patients.
For more information about Pivot Tables, you can check this: https://support.office.com/en-us/article/Create-a-PivotTable-to-analyze-worksheet-data-a9a84538-bfe9-40a9-a8e9-f99134456576
To get the number of unique IDs in the same column, if the IDs are numeric, you can use SUM with FREQUENCY:
=SUM(IF(FREQUENCY($A$1:$A$1000,$A$1:$A$1000)>0,1))
If they're text and numbers mixed, you can get unique IDs with this one:
=SUM(IF(FREQUENCY(MATCH($A$1:$A$1000,$A$1:$A$1000,0),MATCH($A$1:$A$1000,$A$1:$A$1000,0))>0,1))
(From here)
Here you go
You've not mentioned whether an event is optional.
You might want to add extra column H with formula like h2=if(c2="",0,1) with 1/0 and multiply it as well in G.
Basically if column G contains a 1 you include it
Here's what the results of the formula look like:
Revision
Table is sorted by Patient id..
on change of patient id column H contains a 1, it'll be 0 otherwise.
So H2 is hard coded to 1, H3,H4,H6 will evaluate to 1.
So now G2=H2*E2 etc. You can filter by column H.
The beauty of mapping things into binary zeros and ones is you can do multiplication to achieve a logical AND result, whilst at the same time breaking a complex task into a series of steps. You can then apply a filter to the data to get the rows where column G are not zero, and see the totals count. Normally I'd insert a column between header and data on row 2 and then have G2=SUM(G3:G9)
Sum column H for number of patients.

Elegant way to filter duplicates in one column and by values of a second column

I have a spreadsheet with about 20 columns. Column A is numeric. Column B is alphanumeric. I want to filter out rows whose values in Column A are below a threshold. At the same time, I want to filter out rows whose values in Column B are duplicates of earlier values in Column B.
There are many ways to do this. But I am looking for an "elegant" way: a way that doesn't require pivot tables, conditional formatting, or the creation of an additional column. Is there a way that meets these criteria?
A number of posts speak to related ideas. But I haven't found any that speak directly to this problem.

how to calculate the means of 100s of subgroups in excel

I have a spreadsheet with ~8000 records, there are ~400 unique identifiers (i.e. element 101, 102, 103....500) that I need to calculated means for. Is there a simple way to calculate means on large datasets like this?? Or will I have to do =average('select column block') for each subgroup/unique identifier?
Many Thanks
Use the following formula
=AVERAGEIF($A$1:$A$8000,"=IDNUMBER",$B$1:$B$8000)
Where
Column A is your column of ID numbers
Column B is your list that you need the mean from.
If your ID numbers are sequential, you can set up something like:
=AVERAGEIF($A$1:$A$8000,"="&100+row(A1),$B$1:B8000)
And copy that down from say C1 to C500
Alternatively you could make a list of the unique identifiers with another formula and place that unique list in C1 to C500 and then in column D use the following:
=AVERAGEIF($A$1:$A$8000,C1,$B$1:$B$8000)
If you have a header row you will need to adjust your ranges accordingly
The formula to generate a unique list of IDs is:
=INDEX($A$2:$A$8001,MATCH(0,INDEX(COUNTIF($C$1:C1,$A$2:$A$8001),0,0),0))
Use that in column C but in row 2 and copy down. So if your data starts in row 1 you will want to bump it down 1 row.
Create a pivot table with the unique identifiers in the rows and calculate the average of the values.
For data that is clustered up nicely and immediately ready to be handed off for a visual review of the averages try a creating a Subtotal:
Select your data
Go to Data > subtotal (far right on the tab)
On the menu popup in the At each change in field, select the column header name that corresponds to your unique identifier.
Select Average for Use function. Select the checkbox of the column for which you want to find the group's mean.
Select other formatting features if desired (defaults typically work best)
Click okay.
Take a sip of coffee and let the magic happen.

Combine the multiple Match Values in Excel

I want to combine Multiple Match Values in Excel an illustrative picture
the example is in the picture.
I want to concat the the match values in one cell
thanks in advance
How large is your data source ?
Are you considering VBA ?
If you need something quick and dirty, one way could be to use intermediate columns that will add item if they match a given ID. For example, if you have your data in column A and B, then column C could be based on formula_in_C2 = IF(A2="v1",C1&B2,C1).
Expand the formula on the whole column. The last row will give you what you are after. Create similar columns for the other IDs.

In excel - comparing column of items to same array

I'm working in excel.
I've got a column of numbers.
I want to compare this column to another column of numbers and find exact matches. Then show these matches in another column.
I've tried using MATCH but I cannot get one column to move through the numbers in it and the other to stay the same.
Is there anyway to do this?
If your columns are say A and B (and either both with or both without headers) please try:
=IFERROR(INDEX(B:B,MATCH(A:A,B:B,0)),"")
in the first row of data, copied down to suit. The result should be in the same order as ColumnA, so you might want to sort A.

Resources