I've got column which consist numbers of type 000.XX.XX
=COUNTIFS(temporary!$A1:$A200,">=000.11.35",temporary!$A1:$A200,"<=000.11.39")
this formula counts values between 000.11.35 and 000.11.39. But i want to count only unique values. How can I do this?
There is not a built-in function for this, as you can see from the several suggestions of how to accomplish this on the Office support site. If you can, you can switch to Google Sheets, and they have a "COUNTUNIQUE()" function.
As described at the link provided above, identify the unique items, either using a filer (this is static) or through repeatedly using the "FREQUENCY()" function. Then count the unique items in a separate step.
Lets say you have the data set in the first column, first you need to remove the repetitions in a second column with the following array formula (confirm the formula with Ctrl+Shift+Enter)
=IF(SUM((A2=$A$2:A2)*1)>1,"",A2)
this formula lists only unique values
I would remove your first 4 digits of your string to create a float number and then count it with the following array formula:
=SUM((IF((RIGHT($B$2:$B$14,4)>=RIGHT(G3,4))*(RIGHT($B$2:$B$14,4)<=RIGHT(G4,4)),$B$2:$B$14,"")<>"")*1)
Please look at the two images for clarification
view with formulas
normal printscreen
Related
I have list of strings. Every string is in different row. I need to find out how many times any of specified strings occurs in a given range. Any of those strings can also occurs more than once. How could I solve this?enter image description here
I have tried the following formula =SUM(COUNTIF(AS11:AS21,{"aa",bb",cc"...}) (... in context mean the of possible strings).
First get a list of unique values with the Excel function "=UNIQUE"
With the Excel function "=COUNTIF" you can then Count the Values with help of the Unique Values
Formula in B2:
=UNIQUE(B2:B24)
Formulaa in E2
=COUNTIF(B2:B24;D2)
You don't want SUM(COUNTIF()), you just want the 'SUMIF()'.
In your sample image, if you put =COUNTIF(AS$11:AS$23, AQ11) you should get the count of "aa" instances. Just copy or fill that formula down and you should be all set.
I have array of numbers in a single column like this:
I want only that numbers for which corresponding negative numbers exist. If number exist 2 times, but negative number exist only one time, then I wanted to retain one positive and one negative number. Similarly, if number exists 3 times, and negative number appears only two times, then I want 2 set of numbers including positive and negative. In this case, I wanted to get output:
5 2 -2 -5
Orders of numbers are not relevant for me. Please do not use VBA. You can create multiple column and apply filter at the end.
Thank you for the response, but I wanted to get the data in column next to the values. Like:
5
2
-2
-5
Please help.
Here's another Office 365 solution:
Name the data range DATA
Put this formula anywhere: =CONCAT(REPT(-ROW(A1:A100)&" "&ROW(A1:A100)&" ",COUNTIF(DATA,"="&ROW(A1:A100)*IF(COUNTIF(DATA,"="&-ROW(A1:A100))<COUNTIF(DATA,"="&ROW(A1:A100)),-1,1))))
That will output the pairs into one cell.
Here's a slightly modified Step 2, which excludes duplicates: =CONCAT(IF((COUNTIF(DATA,"="&-ROW(A1:A100))>0)*(COUNTIF(DATA,"="&ROW(A1:A100))>0),-ROW(A1:A100)&" "&ROW(A1:A100)&" ",""))
Looks like this:
The data doesn't need to be sorted. Both methods work up to 100, but you can easily expand that by changing A100 to A1000 or whatever you need.
Use the vlookup formula to identify the rows, and you can use the Filter & Unique formula to get the list, or a pivot table.
First, immediately next to your data use the formula:
=vlookup(A1*-1,$A$1:$A$1,1,0)
For non-365:
This will produce an error for each instance that doesn't have a match. You can filter at this point to get your list from the existing table. You can also create a pivot table under the Data tab of your ribbon and inserting a pivot table. Filter the #N/A from there to get an exclusive list without hidden rows.
For 365:
You can use the following combination of formulas to get the exclusive list as well.
=UNIQUE(FILTER(B1:B8,ISNUMBER(B1:B8)),0,0) or =UNIQUE(FILTER($B$1:$B$8,ISNUMBER($B$1:$B$8)),0,0) should yield the same results
As ScottCraner mentioned, you can circumvent the helper column in 365 by modifying the formula a bit more:
=UNIQUE(FILTER(A1:A8,ISNUMBER(MATCH(-A1:A8,A1:A8,0)),"")
The Match here is doing something similar to the Vlookup, but housing that logic within the formula, so it's a cleaner solution in my opinion.
Using your data the result was { -5,-2,2,5 }
These are spill formulas so you only need to put it in one spot and it will expand the formula over the adjacent cells below where it's entered for however many cells needed to list all the unique numbers that occur. It takes into account the negatives and so on. This may be a 365 formula, so if you're on another version of excel it may not work.
Edit: Adjusted the instructions to fully address the question.
This question builds on my previous post regarding how to identify and output multiple instances of a found value. My previous post:
Array to lookup multiple columns and take another columns information
This question is slightly different, where what if I wanted to sum the values found in an array. I have presented an example below. The Table I2:J4 is the reference table which assigns a value to each Plant #. Cells B3:F9 are already filled in and are used to find the sum of one count of each instance in the row. Column A will show the solution of each row. The formula should allow the column to be populated automatically.
For example I have filled in the answer for the first three rows of Column A. In Row 3, we see that there is a Plant 1002B1, and 1003B1 so the answer is 200+300. We neglect any additional instances found of a Plant #. For example row 4 and 5 both have a sum of 100, regardless of how many instances of the same plant are found.
I found myself trying to use an Index but this would return True/False values and because of this you can't add the sum of the value. Unless you use the True/False to identify the location of the value in the reference table and use that to find that the sum, which I dont how to do.
Use this array formula
=SUM(IF(B2:F2<>"",IF(MATCH(B2:F2,B2:F2,0)=COLUMN(B2:F2)-MIN(COLUMN(B2:F2))+1,SUMIFS(J:J,I:I,B2:F2))))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one has the new Dynamic Array formula(currently only available to Office 365 Insiders) then it gets much simpler to get an array of unique entries:
=SUMPRODUCT(SUMIFS(J:J,I:I,UNIQUE(TRANSPOSE(B2:F2))))
I have a sheet with multiple parts belonging to different affiliates and areas. I want to write a formula that brings up the unique part from this list. I created a formula for the data set to get the row number of each unique part as shown below:
I want to just pull the rows from G which began with a 1. I try using the formula below, but it just will pull all the rows in column A:
INDEX(DATA!$A:$A,MATCH(1&"-"&$A$2&"-"&DATA!A2,DATA!G:G,0))
And produce this result:
01949765
01949765
04581664AA
04581664AA
04581914AC
04581914AC
04581914AC
04581914AD
04581915AB
Below is what I want to see:
01949765
04581664AA
04581914AC
04581914AD
04581915AB
Any formula I can use to get just the unique values?
As I understand it, the row already split the unique values, you just have to pull anything in A that has a G counterpart starting with 1.
=INDEX($A$1:$A$8,AGGREGATE(15,6,((LEFT($B$1:$B$8,1)="1")*1/(LEFT($B$1:$B$8,1)="1")*1)*ROW(INDIRECT("1:"&COUNTA($B$1:$B$8))),ROW()-10))
You'll have to adapt the different ranges to your data and the "-10" at the end depending on where you put your result.
My proposal, add a column, put in
=COUNTIF($A$2:$A2,A2)
Then filter only the value = 1. You'll see the results straightaway..
about the parts name in G..
you can load it using index()+match() function. Eg =INDEX(G:G,MATCH(A2,A:A,0)) to 'load' it.
Hope it helps.
I am working on a statistical model where we use sumproduct to generate forecast values by multiplying coefficients in one table with variables in another. Right now it is being done manually and that is taking time. I would like to automate it but I'm not able to figure this out.
We are using concatenate to identify different rows to use for vlookup. The variable columns are the same in number for both tables. I need to multiply each variable cell respectively in both tables and sum them, hence sumproduct.
this is what I am trying to do
Forecast model 1 sales for product A in phones in USA = sumproduct([variables by year from table 1 for USA for phones], [Variables for USA phone product A model 1 from table 2] )
I hope someone can help me.
Proof of Concept
You will need to update the references to suit your spreadsheet table locations.
In cell E21 use the following and copy right and down as required:
=SUMPRODUCT(INDEX($G$3:$I$12,MATCH($B21&$A21&$C21,$A$3:$A$12,0),0),INDEX($F$15:$H$18,MATCH($A21&$C21&$D21&MID(E$20,16,1),$A$15:$A$18,0),0))
This process was simplified because you had a unique ID tag on each of the previous two tables that could be built from the information in the third table. If you ever get into double digit forecast models the MID() function part of the formula will need to be modified. The 16 in the mid function refers to the character location of the number in the forecast model sales header name in Table 3. As such you either need to keep that header format exactly the same or modify the position of the number in the MID() function.
UPDATE 1
Explanation of Formulas
The following formulas were used in this solution:
SUMPRODUCT
INDEX
MATCH
MID
Concatenate
I will start with the assumption that you already understand sumproduct() as you were already using it before you ran into your problem. One thing to note about sumproduct is that it causes array like calculation to occur on the portion within it brackets. In this case we fed it two ranges of equal size. The difficult part was more an issue of determining those ranges.
Using your ID columns as a lookup row we used the match() function to determine which row to use. For the first set of variables we used the following to determine which row to look in:
=MATCH($B21&$A21&$C21,$A$3:$A$12,0)
Match is made up of three arguments inside the brackets:
MATCH(what to look for, where to look, type of match)
What we need to look for in table is a concatenation of various cells in Table 3 to build the ID in Table 1. It could have been written using the full formula:
=CONCATENATE($B21,$A21,$C21)
but the short form using & was used instead:
=$B21&$A21&$C21
Once we had what to look for we needed the range of where to look and supplied the ID column from table 1:
$A$3:$A$12
This now leaves the third and final argument of what type of search to perform. An exact match seemed to be the most appropriate match to perform so the value of 0 was supplied. What match returns is the row within the supplied range. It is relative to the range supplied and not the actual row in the spreadsheet. If it cannot make a match it will return an error instead of a row number.
Now that we know what row we want, we can use this information with the INDEX() function. The INDEX() function is made up of 3 arguments as well with the third argument being optional depending on if a 1D or 2D range is being indexed:
INDEX(Range to work with, 2D Row or 1D Position reference, 2D Column reference)
IN the case we are dealing with for the first table, the range to work with was your list of variables:
$G$3:$I$12
This is a 2D range. As such we need to tell INDEX() both what Row to look in as well as which Columns to look in. For the row to look in, we used the previously discussed MATCH() function. Since we want all columns and not just a specific column we use the value of 0. If Match returns an error, or if a number greater than the number of rows or columns selected is supplied, INDEX() will return an error. Based on the information discussed, the index function would look like:
=INDEX($G$3:$I$12,MATCH($B21&$A21&$C21,$A$3:$A$12,0),0)
You can try entering the above in a cell but it will give you an error. if you select three adjacent cells in the same row and use CONTROL+SHIFT+ENTER when entering the formula, Excel will add {} around the formula and it will be an array formula and should show you the three variables being used.
The same process as described above can be used for determining the second range of variable from Table 2. The only difference here is that the forecast model number was not in a column of its own but instead in the header row surrounded by text. As such the MID() function needed to be used to go into the header row, bypass the surrounding text and pull the model number out so it could be used as part of the CONCATENATION() used for the "what to look for" in MATCH():
=MID(E$20,16,1)
The MID() function work again with three arguments:
MID(Text to look in, which character to start at, how many characters to pull)
So in this case we are looking at the header in E20. Note the lock $ on the row number so the formula is always looking in row 20 no matter how far down it gets copied. It is then going to the 16th character. In this case the character "1" and pulling 1 character. If the header had just been 1 and 2, there would be no need for the MID function and the cell (with proper lock) could have been used.