Excel: how to count combinations that go both ways - excel

I need your help with Excel because I can't seem to find the answer anywhere.
So let's say I have column A and column B and in each column there are different colors. I've already created pivot table to count how many times a certain combination occurs, however, I don't know how to count the same combination of colors that occur in the reverse order as one. For examble combination 1 is red-green and combination 2 is green-red. Pivot table counts these as different entitites.
Thanks for your help in advance.

Two suggestions
(1) Keep it simple
Just set up a helper column containing each pair in alphabetical order
=IF(A2<B2,A2&"-"&B2,B2&"-"&A2)
then run a pivot table on the result.
(2) Make it complicated
List the different pairs using a formula
=IFERROR(INDEX(A$2:A$10&"-"&B$2:B$10,MATCH(1,INDEX((COUNTIF(G$1:G1,A$2:A$10&"-"&B$2:B$10)=0)*(COUNTIF(G$1:G1,B$2:B$10&"-"&A$2:A$10)=0)*(A$2:A$10&B$2:B$10<>""),0),0)),"")
Then count them
=IF(G2="","",SUMPRODUCT(COUNTIF(G2,A$2:A$10&"-"&B$2:B$10)+COUNTIF(G2,B$2:B$10&"-"&A$2:A$10)))
The second way has the advantage that it is dynamic and doesn't need helper columns.
The first way is faster and puts the results in alphabetical order.

Related

Excel automatically sort column of numbers

I am looking to automatically sort a column of numbers in descending order without touching the sort button, or VBA.
Unfortunately I am trying to achieve this in a work environment where I have no access to VBA and excel is not one of the latest versions that contains the new SORT function in 365.
It is quite literally a column of numbers, and the numbers are automatically updated as they are totals of rows of smaller numbers elsewhere, and these change based on something else - so this specific column will always change numbers, but I need the column to automatically keep on top of sorting numbers by descending order.
I tried using rank.eq and some other bits with adding a 1 to each row to avoid duplicates, but this buggered it up if more than two duplicates was found. Is there anything I can do at all? Even if it involves going a very long way round it and building extra tables and things etc.
Grateful for any help.
It'd be easier to see your data and without being able to use a spill range, it's impossible to know how many rows. I also think you're intending to use LARGE function rather than RANK.
If you had your numbers in column A, you could drag the following formula down the appropriate number of rows to get the numbers sorted... (starting in cell B1)
=LARGE(A$1:INDEX(A:A,COUNTA(A:A),1),ROW())
If you can get your numbers in a table, you could use a similar formula but the table would ensure the appropriate rows exist (assume table name is Table1 and note the column names of RawNumbers and Sorted). Put this in Sorted Column:
=LARGE([RawNumbers],ROW()-ROW(Table1[[#Headers],[Sorted]]))
I presume using a pivot table is not a viable option... but these are how you could accomplish your objective of sorting by formula.

Excel Multiple Values for one anwer

Hello looking to solve a problem in excel. Here is an example of my data: Please see attached file.
I am looking to just grab One barcode to one value(Yes/No) for example if I wanted to see how many Yes answers there are its skewed because you can have multiple Yes/No values per barcode. which would count as 2 instead of just one value. I hope this makes sense. I tried a pivot table and everything because we need to set the barcode to a count distinct but I am lost on how to create a formula or something that would work. I cannot Remove multiple values because each line contains data I need since this is just an example.
I think you're looking for countifs. =Countifs(a:a,1,b:b,"yes")
This will only count instances where the bar code is 1 and column b is yes
You can use COUNTA with UNIQUE and FILTER formulas nested. =COUNTA(UNIQUE(FILTER(A:A,B:B="yes")))
The filter formula tells Unique to only look at rows where column B = Yes. Unique then creates an array of just unique entries. While CountA will count how many entries are in the array.
I added some extra entries to the example so it showcases it better. I colored the first instance of each unique entry blue to highlight the instances the unique formula is pulling.

How do you count the occurrence of same data set in two columns-set in excel?

How can we count the occurrence of each set of data? For eg I want to check how many time the customer country in column A comes alongside country in column B ie (How many times Australia-Australia occurs in column A and column B?). The result for unique occurrences are place in right hand side of the sheet. I have found out unique occurrences of the sets and want to count how many times each occur.
You asked for a formula, but a pivot table can do the same thing faster; and without requiring you to create the table for unique countries (option found under insert, usually the first button in the ribbon):
This is how it looks like after pulling the fields in the right 'boxes', the 'Tabular' report layout is selected and the subtotals turned off.
You can make 'Australia' repeat itself too under report layout if so you wish.
Again, SUMPRODUCT is your friend:
=SUMPRODUCT(--(($A$2:$A$11&$B$2:$B$11)=(D2&E2)))
You can use COUNTIFS function as below.
=COUNTIFS(A:A,D2,B:B,E2)
Adjust the ranges to suit your data and copy down.

Returning sum of column for filtered data, without filter

I'm trying to calculate the sum of a column (TSQFT in the screenshot) that is part of a data set, which would be filtered based on multiple criteria using cell references (see screenshot). I don't want to use excel's regular filter as it's a hassle to change the settings and I'd like it to be done in a more automated way.
I've tried {SUMIF} and {SUMIFS} but those do not work as a filter - i.e. for a row to be {TRUE}, the numbers have to be in the same order as that specified in the criteria list {5-7-2} (see screenshot).
Would much appreciate any help.
You can try something like this:
Make 3 column of =IF(OR(C3=$C$10;C3=$D$10;C3=$E$10);1;0) formulas, one more column for a sum of this 3 column and a sumif based of the sum values
if the sum is 3 then the value is good.
This maybe the worst solution for this but as long as it can help, it can be developed into something better.

Count duplicate values in a column, filter the results as unique values then sort largest to smallest

I have a large list of brands that includes dozens of duplicates for each value. I would like to count how many times each value appears in the column, then to sort the count results largest to smallest & then to finally display the results (both the value and its count) as unique values, for example;
I would like this:
Nyke
adodis
Redbook
Nyke
Nyke
Redbook
Nyke
To become this:
Nyke (4)
Redbook (2)
adodis (1)
I understand that this can be done using sort & filter, pivot tables etc. as well as using the COUNTIF formula but would like to know if it is possible to achieve all steps using just formulas?
Thanks!
You can use the "remove duplicates" on a copy of the data, then use "COUNTIF" to get the count from the original column, then give each row a number from "RANK.EQ" then finally sort the new table.

Resources