How to categorize this data by frequency of another column? - excel

I have several columns of data that need to be sorted into tables. What I would like is to go through each purely numerical column on the left and "a" column of the right. With two columns fixed, extract all unique values from the value column (there could be any number of them, but no repeats). Then I want to count them according to their category: a0 or aN where N>0. There's a fixed number of categories. It should result in the following table:
Example with test data
(6 tables should be produced in all for this example)
It should work in Excel 2007 for compatibility reasons. How would this be done? Is a VBA macro necessary?

Related

Get duplicates from two columns

I'm having trouble filtering an excel table. M, it is a set of two rows from two tables, where it is necessary to find duplicates.
2 rows with duplicates
Some idents are repeated, they are present both in the current and previous months. In the example below, with the help with this function =IFERROR(MATCH(A2;B:B;0); "NO"), I obtained information about which data from last month is repeated in the current month and exactly in which row it is located. The code for determining whether it is repeated is as follows =COUNTIFS($A$2:$B$13;A2)>1
duplicates and if repeated
I would like to retrieve only duplicates from the list, I tried the code =IFERROR(INDEX(A:A;SMALL(IF(NOT(D$2:D$104=TRUE);ROW(B2)-ROW(INDEX(B2;1;1))+1);ROW(G:G)));" ERROR")to get the ones that are repeat and skip those ones that arent, but the result is not as desired. In line G, you can see an example of how Excel gives me data regarding the entered function. In cell H, it is shown how I would like a new row to be created with only duplicates.
Current vs. desired display
In this example, the columns are a bit small, but in reality there could be at least a thousand rows, so I would need help filtering those.
You implied these columns were present in two different tables. So I used Tables with structured references. You can convert to normal addressing if you require that instead.
If you have Windows Excel 2021 or later, you can use:
=FILTERXML("<t><s>" &TEXTJOIN("</s><s>",,UNIQUE(LastMonth[Last month marks],FALSE,TRUE),UNIQUE(CurrentMonth[Current Month],FALSE,TRUE))& "</s></t>","//s[following::*=.]")
Create a list of distinct items for each row
Create an XML by concatenating the items into an array using Textjoin
Extract only those items that are followed by an identical item
With your earlier version of Excel, again, I would still use Tables and structured references but I would also use a Helper Column
D2: =IFERROR(MATCH(lastMonth[#[last month]],currentMonth[current month],0),"NO") *and fill down*
E2: =IFERROR(INDEX(currentMonth[current month], AGGREGATE(15,6,[Duplicates in Which Row],ROWS($1:1))),"")

Return all matches in columns using one criterion (from drop down on another sheet)

I am having two tables, one table (table 1) below is main data, separated into many columns and blocks per 10 rows in one, as you can see A2:A11, A12:A21 and so on (many rows and columns) ... In Column A are unique numbers, but one number per block as a unique, and all other information in other columns can differ, sometimes will be more data sometimes not. The data is always same structured.
What I am looking is to have report / printable sheet where I will have all my columns on one sheet, but in a Column A2 for instance drop down list that will use all unique numbers from main data table and populate all matches on report page, same as it is on picture below. There are many columns that should work automatically when I choose something from "Number" drop down. The trick here is, there must be 10 rows per block also, I have organized it as it should be, but I can't figure out how to populate using functions. So, you can imagine clicking one drop down and getting those lists updated without scrolling endlessly through columns and rows on main data table...
Where I have a problem is that I am getting matches only for first rows but not whole rows (or all rows where matches are) ...
using this function:
=INDEX(Table1[Datum];SMALL(IF(Table1[Nummer]=Printable!$A$2;ROW(Table1[Nummer])-ROW(INDEX(Table1[Nummer];1;1))+1);1))
If someone can help me out, I would be happy!
Try below formula. After putting formula to cell drag down and across as needed. I have tested this formula in Excel2013 and with range (not as table). So, you have to adjust formula for table. I suggest you to first test the formula in single sheet like my screenshot and if it is successful then go for table in Report sheet.
=INDEX(INDEX(B:B,MATCH($G$2,$A:$A,0)):INDEX(B:B,MATCH($G$2,$A:$A,0)+9),ROW(1:1))

How to get distinct count within pivot table(Excel for Mac) having filters?

Excel for Mac doesn't support Power Pivot and thereby doesn't have distinct count feature.
What is the best workaround to get distinct count in such cases?
Sample Excel Columns:
Period Criteria1 Criteria2 Criteria3 Data
Sample Pivot table:
Different values in 'Period' will be pivot columns.
'Criteria1' can be a filter to pivot table.
Both 'Criteria2'&'Criteria3' columns can be pivot rows.
Now, count of 'Data' can be obtained directly through pivot.
How to obtain distinct count of 'Data' ?
Answer Options
Using 'Countif' on raw data - Cons: Very slow on large data.
Counting unique keys made by concatenating Criteria columns - Cons: Gets complex and takes more effort in large data with many criteria columns
Is there any better workarounds to obtain distinct count within pivot table(Excel for Mac) having filters/multiple criteria's?
I think I had a comparable problem and here's how I "fixed" it.
Add a column to the table named "DistinctValue" - or "Crit2:Crit3" doesn't matter
Add a formula, concatenating the values from all fields you have as a row in your pivot table: =[#Criteria2]&":"&[#Criteria3] -
depends a little bit on your values, but for me : as concatenator
works fine. Space or no character may also work.
Add a column "Distinct"
Add a formula: =IF(MATCH([#DistinctValue],Y:Y,0)=ROW([#DistinctValue]), 1, 0)
Use this row in the pivot as a value with SUM and name it "Count".
This gives you a 1 for every first row of distinct values in your data table which is used in your Pivot. The data rows used for the pivot table should have exactly one row with a 1 for each section of rows. If you sum it up, you exactly get the distinct count.
If you add a new row to the pivot, you need to add it to the formula in 2. to get distinct values again.
Edit: You probably have to exchange , with ; for other languages in the formulas when also translating the formula names to German for instance.
The following solution has a few steps, but the payoff is that it scales very nicely, because the formula is just as performant on large sets as on small ones, as opposed to lookup/match which get slower the larger the set is.
(1) Custom sort on the fields with the duplicate values. e.g.
"Email Address"
n.b. If you prefer to count a particular instance (i.e. the record with the latest creation date), set the sort so that those duplicates will appear first.
(2) Create a new column, Call it Unique Count or what have you. In that column use a formula that is 1 if the preceding value and current value are not equal. E.g. =IF(EXACT(A2,A3),0,1)
(3) Fill down.
(4) Pivot on this table. Now when you do Count/Sum, use the Unique Count.

Count unique items on a list that meet multiple criteria

This sounds simple, but I'm getting a real headache trying to figure it out:
I have two tables in excel in the same workbook but on different sheets. I want to count unique items in column B on the first table that meet a criteria (based on the data that's in column A of that table) and appear on the second table (on a different worksheet).
Because the data I'm working with is confidential, I've made up the two tables below (I've just clipped .jpgs). They are similarly formatted, but in reality I have much more data.
I need a formula that counts the number of unique people in Column B of Table 1 who also appear in Column B of Table 2 and whose date (in Column A of Table 1) is on or before 4/2/2016.
In this example it should come out with the answer three (for Bob, Jim, and Sue).
Table 1
Table 2
Any help you can provide would be hugely appreciated!!
If you put this =IF(AND(COUNTIF('Second Table'!$B:$B,'First Table'!$B2)>0,$A2<DATE(2016,4,2),SUMIF(B1:$B1,B2,$C$1:$C1)=0),1,"") in C2, then auto-fill it down would do it and you could sum it then at the bottom..

Distributing rows of small table based on values of a bigger table (Excel)

I have two tables of different lengths in Excel. The first column of the biggest table contains all the values of first column of the smaller table (and more). I would like the rows of the small table to be distributed to match the big table (creating empty rows when the values are missing). I would like to use a formula for this if possible (VBA code alternatively). I cannot do this manually because the actual tables I am working with have thousands of rows. Here are pictures describing what I am trying to do:
Initial lists
Result
EDIT: I should add that the first columns of both lists in the examples are numbers, but in the real lists I am working with the values are composed of letters and numbers
Any help would be greatly appreciated!
Thanks
I moved the "small" table over to make room for the results. I put them in F and G.
Then in C1 I put this formula:
=IFERROR(VLOOKUP($A1,$I:$J,COLUMN(A:A),FALSE),"")
Copy it over on column and down the extent of the large table.

Resources