how to count unique values by certain criteria? - excel

Say if I had the following sample table:
Country Year
USA 2010
USA 2010
USA 2010
Australia 2011
India 2010
China 2010
Output should be:
2010: 3 (USA, India, and China)
2011: 1 (Australia)
2012: 0 ()
I am trying to count the unique number of countries during a certain year.
I having trouble how to get the nested conditional count working.
Any help would be greatly appreciated.
I cannot use VBA, i must use native excel functions or pivot tables.

Copy and paste your data into a new worksheet to allow you to play with it.
Remove Duplicates (Data>Data Tools>Remove Duplicates) based on country and year.
Then sort ascending with filter based on year (Data>Sort & Filter).
Then subtotal a count (Data>Outline>Subtotal) based on change in year.

I think you can get some way there by concatenating Year&Country and then do a count within a pivottable. The only problem is that you can't get a zero. This also won't lay it out in the way it looks like you want but is that important?
If so, then a formula might help which would list unique entries in a range (again utilising the concatenated column)......
I have developed a formula which does this using countif:
Hope this help you or someone else need to list and count unique values.
Just adding a link to share the excel file I've created. Enjoy. Excel file

Related

How to sum value of the same products according to the year they were sold?

I have an excel sheet with the list of all the products sold in different years. I need to display separately the total price of the each product that was sold in 2016 only:
and I need to get all the prices of the products sold in 2016 ( for each product separately) and create a new table like this
So if there are 100 laptops sold over the years, I need to create a new table with total price of the sold laptops in 2016.
I tried to achieve this by using sumif, but I can't figure out how to write correct condition. Any help would be greatly appreciated.
Add anothercolumn to identify the year sold, e.g =year(a2). Create a pivot and filter on the new column.
Here is the SUMIFS formula that escaped you.
=SUMIFS($C$2:$C$8,$A$2:$A$8,">"&DATE(G$1,1,0),$A$2:$A$8,"<"&DATE(G$1,12,32),$B$2:$B$8,F3)
In the picture below it is in cell F3 from where it can be copied down.
By simply changing the year in G1 you can get the results for different years. So, you could create a list of all items with a column for each year and see the results side by side.
The formula for finding the SUM for all products depending on the DATE:
=ARRAYFORMULA(SUMIF(YEAR(A:A); 2016*{or your reference cell}*; C:C))
The formula for finding the SUM from both DATE and CATEGORY:
=ARRAYFORMULA(SUMIFS(C:C; YEAR(A:A); 2016 *{or your reference cell}*; B:B; "laptop" *{or your reference cell}*))
It won't work without ARRAYFORMULA and be careful with quotes,

Excel - Get unique count based on multiple columns (including date)

I'm trying to get a unique count of data in Column B that fall into the month of June (Column A date field)
Screenshot of Spreadsheet
I highlighted the rows that fall within June in Orange and the duplicate data in red to make it easier to view.
Count Total formula is a simple:
=COUNTA(A:A)-1
Unique Data formula is:
=SUMPRODUCT(1/COUNTIF(B2:B21,B2:B21))
Count June formula is:
=COUNTIFS(A:A,">=01/06/2020",A:A,"<30/6/2020")
But I can't figure out how get a count of unique data that falls within June (expected result is 13)
I've tried filter/unique formulas based on
Excel - Count unique values that meets multiple criteria
But I just can't get it to work. I know I could do it with VBA but this is part of a larger spreadsheet and every other part of the spreadsheet I've been able to do with Formulas, so would like to be able to do this last part with formulas too.
Anyone can help will be a life saver, it's been driving me nuts for the last couple hours.
In Excel 2016, which does not have the UNIQUE or FILTER functions, you can use this somewhat convoluted formula for a Unique count of June entries:
=SUM(IF(FREQUENCY(IF(LEN(IF(MONTH(Table1[Date])=6,Table1[Data],""))>0,MATCH(IF(MONTH(Table1[Date])=6,Table1[Data],""),IF(MONTH(Table1[Date])=6,Table1[Data],""),0),""),IF(LEN(IF(MONTH(Table1[Date])=6,Table1[Data],""))>0,MATCH(IF(MONTH(Table1[Date])=6,Table1[Data],""),IF(MONTH(Table1[Date])=6,Table1[Data],""),0),""))>0,1))
This part of the formula: IF(MONTH(Table1[Date])=6,Table1[Data],"") returns an array consisting of all of the June Data entries.
The LEN(... eliminates the resultant blanks
The Frequency function will then have us wind up with a count of 1 for each entry.
Then we just add it up.
Note that I used a Table and structured references, but you can convert it to regular addressing if you need to.
Of course, if you had Excel O365, you could use the simpler:
=COUNTA(UNIQUE(FILTER(Table1[Data],MONTH(Table1[Date])=6)))

How to extract data using two Filters in Excel?

I am school student and new to the Forum and I need help with some problems.
I have been lately trying to build a Inventory Sheet in Excel, where there is a table of Partnumber, Responsible Department, Delivered Calendar Week and Product type.
I want to filter the data using two filters, for example: The parts that has been taken by customer on calendar week KW(10).
And I then need to take the total number of this filtered parts to another sheet.
Can anyone help me with this?
There is no need for VBA. You can use a simple formula for this in the example shown below:
=COUNTIFS(Tabelle1[Responsible Department],$F2,Tabelle1[Delivered KW],G$1)
Enter this formula in G2 and copy it to the other cells. Tabelle1 is the name of the formatted table.

Excel Formula to Compare and Import Certain Information between Sheets

I am working on a new spreadsheet that is an update to a spreadsheet from last year. I'm trying to fill in blank columns for this year's data by importing them from the other sheet. However, the order and information has changed from last year and I'm looking for a way to fill the columns in the correct row by comparing only the information that corresponds to the same information from last year.
I have these columns in both sheets:
2014 Rank - 2013 Rank - Address - City - Zip Code
I need to create a formula that will compare the Address, City, and Zip Codes from both sheets and then insert the 2014 and 2013 Ranks into this year's data in the corresponding rows.
The issue is that the ranking from this year has completely changed the order of the rankings from last year so the formula needs to know to search the entire sheet. Any help would be greatly appreciated!
You can create another column in each sheet, concatening the Address, City and Zip with =CONCAT(A1,CONCAT(A2,A3)) and then use =VLOOKUP() to search on this new column.
More info on VLOOKUP (Theres working examples on how to retrieve more than one column and several other stuff):
https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1

do sum filtered by year

Hi want to create some report using data what I have. Below is what I have.
Date Sold
22-Oct-11 22
23-Oct-11 28
24-Oct-11 10
22-Oct-12 22
23-Oct-12 28
24-Oct-12 10
What I want is create year and sold total as below.
Year Sold
2011 60
2012 87
Any idea how to get this done using excel pre-defined function.
I know this can be done using MACRO, however I don't want to use MACRO.
Edit 1
I don't want to do this using Pivot too. ONLY Excel pre-defined functions.
It's possible to use an array formula (Ctrl-Shift-Enter in formula window to enter, the curled brackets will be inserted by Excel, not by user):
={SUM(IF(YEAR(A1:A4)=2010,1,0)*B1:B4)}
Dates are in column A, sold quantities in column B.
Try this formula: =SUMIF($A$2:$A$7;"=*11";$B$2:$B$7).
I think it's possible to improve this formula, but I'm just a beginner.
If you can add an extra column for =Year(date) then you can use Subtotals to calculate your results (Data-Subtotals)
you can use a pivot table. put the date field on the left, right click and Group by year and put the sold field in the values area
With Excel 2007 (and later), you have access to the SUMIFS function
Assuming your data is in columns A and B, in the order shown, then a function to add up all the data in 2011 would be
=SUMIFS(B:B,A:A,">="&DATE(2011,1,1),A:A,"<="&DATE(2011,12,31))
of course, you can reference a cell containing the year number in place of the 2011 to make it portable

Resources