Suppose we have following data
prices
leptop 30
pc 29
table 10
house 15
car 25
train 32
pen 45
dog 33
cat 17
TV 8
I have calculated average of these prices avg==AVERAGE(D3:D12) where D3:D12 are price columns. Now I want to choose these items or list items which has price less than average for example, I know there is function if, but how can I use it together to list all data, which satisfies the if condition?
Are you trying to list the prices that are less than the average all in the same cell?
If you're just trying to indicate whether they are or not next to the column, you could use: =IF(D3 < AVERAGE($D$3:$D$12), "Less Than", "Greater or Equal")
Edit:
http://i.imgur.com/SRTfvJe.png
Ok, to get the result you want (see image) then you need to use the following formulas (this assumes these formulas are in column F).
The first row in the column should be: =IF(B3 < AVERAGE($B$3:$B$6), A3, "") where B3 is the data and A3 is the name.
And all the other rows should be: =IF(B4 < AVERAGE($B$3:$B$6), IF(F3="", A4, F3 & ", " & A4), F3) where B4 is the data and A4 is the name.
This is how you could do with with Advanced Filter. Set-up your excel sheet as follows, and enter the formulas appropriately:
Then, go to Advanced Filter:
You will get:
In E3 and copied down:
=IF(D3<AVERAGE(D$3:D$12),C3,"")
will give a list (admittedly with spaces) if the names are in ColumnC. (Guessing that 'continue' does not mean the same cell.)
Does a filter work for your needs? If I go to the "data" tab in Excel 2010, highlight the data, and click "Filter", I can filter on items "below average" in the price column.
Related
I need to be able to sum the total payout amount given that there are multiple entries for the same user. In addition, I have a dropdown data validation reference cell that should show a smaller total sum based on payout_amount.
For example, total sum is 1,270. But if I am just looking at payout_amount for loss_type = 'Theft', the sum is 750.
How would I do this in Google sheets? How would I do this for multiple criteria (multiple dropdown data validation)?
user_id.
loss_type.
payout_amount
1
Theft
500
2
Theft
250
3
Liquid Damage
180
3
Liquid Damage
180
4
Liquid Damage
225
4
Cracked Screen
225
4
Cracked Screen
225
5
Battery Malfunction
115
5
Battery Malfunction
115
5
Battery Malfunction
115
You need SUMIFS() function for multiple criteria. Try below formula-
=SUMIFS(C2:C11,B2:B11,D2)
You can add more criteria for more dropdown value like
=SUMIFS(C2:C11,B2:B11,D2,A2:A11,E2)
Try QUERY.
=query(B1:C,"select B, sum(C) where B is not null group by B",1)
It's just one short formula and works for the whole range.
SUMIFS and UNIQUE is highly effective for your case.
Create dropdown from all items of loss_type. Try formula UNIQUE(B2:B) on cell H2 to get the list of all loss_type.
Create dropdown on E2.
Select E2 > Go to Data > Data Validation > Criteria (List from range) > Select H2:H
Then, use SUMIFS with the dropdown value as criteria on F2. Try the formula below -
=SUMIFS(C:C, B:B, E2)
This should automatically provide you with a total sum payout, once you select your required value in E2.
I've got a pretty complex conditional formula that works for each row of a column (sorry, no excel 2016 IFS) and I would like to get the sum of all instances in a range in one formula without having to make all the rows as a middle step.
Done this quite a bit with other stuff, but for some reason I'm stuck on this one.
The formula per cell is:
=IF((IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<1),0,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<2,1,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<5,2,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<13,3,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<34,4,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<91,5,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<245,6,IF(IF(IF(AND(ISNUMBER(Test_Samples!B2),Test_Samples!B2>0.1),Reference_Dataset!$H:$H,"")="N",Test_Samples!B2,0)<666,7,))))))))
I would like to transform it to a formula that sums everything from the range B:B (or B2:B499) in one go.
I tried some SUM and SUMIF(S) stuff and changing B2 to B:B. That doesn't seem to work.
Oh, if someone has a tip to reduce the nested IF formula to something more readable, that's welcome as well. The idea of the formula is to transform counts to classes.
The datasets that are referred to look like this:
Test_Samples:
Reference_Dataset:
The If statements make up a classification as follows:
0= 0
1= 1
2= 2-4
3= 5-12
4= 13-33
5= 34-90
6= 91-244
7= 245-665
8= 666+
Here you see a count of 2 in "Test_samples", and it is labelled "N" in "Reference_dataset", so the result classifies it as "2" (to avoid confusion: if the count was 5 it would be labelled "3" according to the class criteria).
Say if there are 5 instances with result "2" in the range B2:B499, the sum should be 10.
Create a lookup table like this for your "result value < X" to summarize the If statements into a single lookup table:
Test_Samples B Value
0
1
2
5
13
34
91
245
666
In this example, i've put that on the same worksheet that the formula is placed, in cells A1:A10 (header in A1, so data values in A2:A10). Then you can simplify your formula and make it reference the range of your data like this:
=SUM(MATCH(IF(ISNUMBER(Test_Samples!$B$2:$B$499)*(Reference_Dataset!$H$2:$H$499="N"),Test_Samples!$B$2:$B$499,0),$A$2:$A$10)-1)
Note that this is an array formula and as such must be confirmed with CtrlShiftEnter (instead of just Enter).
I have data in Excel in the format:
Type: Price:
A 10
A 20
D 30
A 50
D 60
How can I get average price of each category (A, D)?
To be clear:
Data given in figure is just example for simplicity. Actually I have 13000 rows with that kind of data with 99 categories distributed in rows and given a 'Price' in second column.
Put this in E3 and drag down till E6:
=AVERAGEIF(A$3:A$16,D3,B$3:B$16)
I suggest a PivotTable.
Based on your data sample:
Here is the formula for averaging in excel. Just change and/or add cells as desired and enter it all into the cell you want it to display in.
=AVERAGE(A2:A6)
I have an excel sheet containing two columns of data that I'd like to rank.
Suppose we have the following:
A B
Franz 58
Daniel 92
Markus 37
Jörg 58
I would like a formula to rank the above data based on column B, and where there are duplicate values (Franz and Jörg) to put the alphabetical name first. What I have at the moment is simply duplicating Franz twice:
=INDEX(Name,MATCH(A2,Points,0))
Can someone advise me of formula / code that will rank the data and arrange duplicate values alphabetically?
Thanks
I would add a helper column in next to your data to help out with ties.
so in column C use
=B1+1/COUNTIF($A$1:$A$4,"<="&A1)/10
This will add on a decimal ranking system based on the name. This assumes that your numbers in column B do not have decimal places, if they do then you will need to increase the 10 on the end of the formula to account for it ie: for 2 decimal places use 1000, 3 : 10000 etc
Use this formula to get the first name
=INDEX(name,MATCH(LARGE(points,1),points,0))
adjust the 1 to 2 for the second name etc
EDIT had the sign around the wrong way
This will rank your data and will not repeat duplicates too:
In C2:
=SUM(1*(b2>$b$2:$b$5))+1+IF(ROW(b2)-ROW($b$2)=0,0,SUM(1*(b2=OFFSET($b$2,0,0,INDEX(ROW(b2)-ROW($b$2)+1,1)-1,1))))
CTRL+SHIFT+ENTER to turn it into an array
Drag these down to C5 and it will not duplicate rank where the name is the same, it will rank them alphabetically if they are the same.
Then if you wanted to order them automatically in order of top performer/score you then do this:
Putting this in E2:
=INDEX(A2:A5,MATCH(LARGE(C2:C5,ROW()-1),C2:C5,0))
...and drag down
Then use a vlookup on your data to return the score putting this in F2:
=vlookup(E2,A2:C5,2,false)
...and drag down
This should give you a table of highest scoring people in score order.
Assuming A2 is the first of the ranked points scores try this version
=INDEX(Name,SMALL(IF(A2=Points,ROW(Points)-MIN(ROW(Points))+1),COUNTIF(A$2:A2,A2)))
confirmed with CTRL+SHIFT+ENTER and copied down
Requires the Name list to be sorted because names with duplicate scores will be listed in the order shown
(http://stackoverflow.com/questions/5283466/calculate-moving-average-in-excel seems to be somewhat related. I'm curious to know the non-vba way to do this.)
My my pivot table has source data that creates a count of how many sales a person had in the past 36 days. Each day os 1 column in the pivot table, and the persons name is on the row.
Some of these people did not have sales on day1, day2, etc, and may only have 3 days where they sold something on days 14,15 and 16. No matter what their sequence, I want to to find the most recent sale data (closest to the right edge of pivot table) and calculate three sales increases e.g. C20/C19 will be >1 if they had more sales on the whatever day C20 is. The increase ca nbe fond by subtracting 1 and changing to percent. The problem is, if a person only had sales on d10, d11, d12 then how can I put a general formula in Excel to say "look for the most recent consecutive sales, then calculate this ratio"? For a person who had sales in the past three days, that's easy. It will be chaotic to hardcode where to look for each sales value.
d1 d2 d3 d4...d7 d8 d9...d34 d35 d36 mostrecentincrease nextrecent
ant 1 5 7 7/5=1.4 5/1=5
bat ...10 11 12... 12/11=1.blah 11/10=1.1
cat 2 6 9 13
dog 19 20 20/19=1.blah 19/blank=0
elf 4 4/dnexist=0
i don't have excel here, but i hope this will guide you to the correct result (use , instead of ; if that is your list separator):
define sales as a range of values from d1 to d36 for a given row (or use actual ranges)
compute positions of the last values for each row using these array formulas (use ctrl+shift+enter instead of just enter after you write these formulas):
position_1 =max(if(sales<>0;column(sales)))
position_2 =max(if((sales<>0)*(column(sales)<>position_1);column(sales)))
position_3 =max(if((sales<>0)*(column(sales)<>position_1)*(column(sales)<>position_2);column(sales)))
retrieve the values:
value_1 =index(sales;position_1)
do some error handling (=iferror(...;0)) and the like...