Filter excel pivot table by complex combination of several fields - excel

Let's assume I have an excel table with at least 3 columns, "Text1", "Text2" and "Number". Text1 and Text2 obviously contain textual content and Number is a numerical value. I create a pivot table from this table with Text1, Number and Text2 in the rows (in this order). I do already group my results by ranges of Number.
I would like to filter my pivot table so that I only include results, that share a value of Text1 with at least one other entry, while also being the same range of Number and while having a different value for Text2 than the other entry (the one they share Text1 with).
Is this possible? I don't mind adding additional fields to the original data table for calculations if necessary.
Example
Let's say I have a table that contains the fields FirstName, Sex and Age like this:
FirstName Age Sex
Kim 19 Female
Kim 57 Female
Kim 20 Male
Tom 23 Male
I group my ages by steps of 25, so 0-24, 25-49 and so on. In this case I would like to only find all the Kims in the same age range that have a different sex.

Thanks to Ilia's comment, I was able to find a solution. I needed three additional columns in my table:
Concat: The concatenation of my Text1 and Text2 field
Group: A field that calculates the groups of my Number field (using QUOTIENT)
Count: This field uses COUNTIFS to count my fields if there are other matches in the Concat column that have the same value as this has in the Concat column and the same for my Group column.
I am now able to use my Count column as a row in the pivot table (below Text2) and add a label filter to check if the value is greater or equal to 2.

Related

Finding the values that don't match from one sheet inside a few cells of another sheet

I have an excel document with two sheets sheet1 and sheet2. Sheet1:
ID number Name
123 John
321 Pete
Sheet2:
Book Comment Comment2 Comment3
Harry Potter My ID number is 123
TLOTR The book is ripped ID: 321
Dune Nice book ID is 999 None
I would like to search the column "ID number" from Sheet1 inside the text in the columns "Comment", "Comment2" and "Comment3" from Sheet2, and return the whole row from Sheet2 of the IDs that don't match.
So, in this case, the return would be:
Dune Nice book ID is 999 None
I have been trying the vlookup, I know how to search inside a text, and how to search inside multiple columns, but I don't know how to mix both processes
It looks like you have two problems.
Your ID or key to link the two spreadsheets together must match the data type. For example, one sheet you have ID number: with a list of only numbers. The other sheet you have text and numbers.
Try Xlookup instead.
Both columns you're using as the matching key has to be the same data type (letters or numbers)
First, use Text to columns (in tools, Data - text to columns) to separate your ID numbers from the rest of your text string in your sheet 2 columns that contain the Id numbers.
= Xlookup(CellwithfirstIDnumber,Columnfromsheet2tosearch, Column from sheet2tobring back, "no match")
Good luck

Custom sort in excel , by each account name and then by cost

I have an excel like
I want to sort the value by the Second column but
I want to retain the "yellow" colored rows containing total values as well after each sorting group, so the expected output will be BARBIE MEDICO first then the total sum of BARBIE, then RAJESH ..
When I tried Sort Box with Name and Then BY, all cost ( yellow) rows are coming on the top
Another example

Irregular Range Average Based on Common Value in ID

I'm trying to average groups of numbers which share a common value in one column but do not have a consistent number of rows. Simplified example of the problem below:
ID Value
Cat 2
Cat 3
Cat 5
Cat 8
Dog 1
Dog 6
Dog 3
Fish 3
Fish 9
So I'd like to find a single average of the values for each of the groups Cat, Dog, and Fish.
Note: I have just over 13,000 rows and 596 unique IDs shared amongst those 13,000 data (all positive decimals).
Select your data.
Go to Insert, Pivot Table
Select a destination for the Pivot Table
Drag the fields from the field list such that ID is a Row Label and Value is in the Values section:
Click on the downward arrow beside the Value field and click on Value field Settings.
Change the Summarise operation to Average.

How to sort a column (with additional columns) to match another column in Excel 2010?

How do I sort multiple records (rows) in Excel to match a specified order by providing a column that it should match?
So lets say for example I have records in a worksheet as below:
Name Age Sex
Tom 20 M
Andrew 30 M
Mike 33 M
And I want to sort the records looking at the first column (Name). Not alphabetically but by any order I prefer. For example I want to sort it so that the first column matches this order so I provide a separate column as:
Andrew
Mike
Tom
So in this case I want the entire record set (name, age, sex) to be moved around to match this order. So final should output should look like:
Name Age Sex
Andrew 30 M
Mike 33 M
Tom 20 M
Trying to do this in Excel 2010, so I'll have both the table data and match column in the same worksheet. How can I do this?
Thanks
In your data sample, the desired sort order is alphabetical by first name, for which you can just use the built-in sort functionality.
If you want a custom sort order, create a custom list, as pointed out by pnuts in the comment. Click File > Options > Advanced > find the button Edit Custom Lists and create a custom list.
Alternatively, create a helper table. Put the names in the first column, in the desired order. In the next column number the cells from 1 to the end, so now the sort order number is in that column. Add a lookup column to your data table and perform a =vlookup(name,HelperTable,2,0), copy down, then sort the table by that helper column.

Sumproduct using 2 criterias and on filtered values

I have the following source table
Date | fruit | veg
The user has previously filtered the date by month. In another table, I want to count the number of apples and tomatoes for example. To remove the invisible rows I use the SUBTOTAL function as
=(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)))
where 'limiter' is the date range.
Then to count the number of apples in the fruit column , I use
= SUMPRODUCT(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)) * Table!fruit = "apple"
and it works fine.
But, if I want to add in the vegetables criteria along with the fruit, the result is 0. I tried doing the sumproduct of fruit and veg first and then add the subtotal function but it gave a huge number.
Have you considered using a pivot table? (I strongly recommend you to)
Go to a new tab, select A1 and insert, new pivot table. You can put the fruit field in the column (probably row labels - my excel is in Portuguese =/). You would instantly have a table containing as first colum the list of existing fruits.
Then add the date to the body (probably values) of the pivot table and certify the type of value shown is count.
You would intantly get the count of all fruits.
The great advantage is that you can play around with this table as easily as dragging and dropping fields in columns, rows and body/values and instantly getting the results you want without having to figure out any formula issues.
Pivot tables also allow you to filter not only the date, but any other fields you wish.

Resources