Compare column A with column B and return minimum value in column A in Column C - excel

Here is my table. I want to return the minimum value from column A in column C only if the values in Column B are equal.
A B C
1 Price Category Lowest Price Per Category
2 240 19
3 231 19 231
4 233 19
5 450 12
6 438 12
7 425 12 425
8 674 33
9 675 33
10 671 33 671

You could try the SUBTOTALfunction and use this formula in the column for lowest:
=IF(A2=SUBTOTAL(5;$A$2:$A$4);A2;"")
You would have to manually adjust the locked range ($A$2:$A$4) for every group though so that it matches the range for the group.
Or if your happy with getting the min value for each group on a separate row under every group you could just mark the two columns (including header row) and use the Subtotalbutton on the Data tab set like in this image:
Then the result would look something like this:
Price Category
240 19
231 19
233 19
231 19 Min
450 12
438 12
425 12
425 12 Min
674 33
675 33
671 33
671 33 Min
231 Grand Min

Try using this formula in C2 copied down
=IF(COUNTIFS(B:B,B2,A:A,"<"&A2),"",A2)
COUNTIFS here counts rows where the category matches and the price is lower than the current row. If there is no such row then the current row price must be lowest for that category and the price is returned.
If there are tied lowest prices within any category then they will all be shown

Related

Change array of SUMIF in case criteria exists in two different columns

A B C D E F
1 Results List A List B
2 Campaign Sales Campaign Sales Campaign Sales
3 Campaign_A 1.510 Campaign_A 500 Campaign_B 50
4 Campaign_B 120 Campaign_A 450 Campaign_B 40
5 Campaign_C 90 Campaign_A 560 Campaign_B 30
6 Campaign_D 1.650 Campaign_B 700 Campaign_C 80
7 Campaign_E 100 Campaign_B 710 Campaign_C 10
8 Campaing_F 70 Campaign_C 200 Campaign_F 70
9 Campaing_D 850
10 Campaing_D 800
11 Campaing_E 100
12 Campaing_F 320
13 Campaing_F 360
14 Campaing_F 290
15
16
The Excel table above consists of:
List A = Column C:D
List B = Column E:F
In each list campaigns can appear mutliple times.
In Column A:B I want to sum up the sales per campaign from the two lists using the SUMIF formula:
=SUMIF(C:C,A3,D:D)
=SUMIF(E:E,A3,F:F)
However, the List B should be prioritized over List A which means in case a campaign exists in List B (Column E) the SUMIF function should be only applied to List B and List A should be totally ignored.
The formula might look something like htis:
IF campaign exists in Column E then SUMIF(E:E,A3,F:F) else SUMIF(C:C,A3,D:D)
How can I achieve the desired results in Column B?
Or,
=IF(COUNTIF(E:E,A3)>0,SUMIF(E:E,A3,F:F),SUMIF(C:C,A3,D:D))
I would try with the following:
if(sumIf(E:E,A3,F:F)>0;sumIf(E:E,A3,F:F);sumIf(C:C,A3,D:D))

Excel SUMIF based on array using text string

Is there a way to substitute the cell address containing a text string as the array criteria in the following formula?
=SUM(SUMIF(A5:A10,{1,22,3},E5:E10))
So instead of {1,22,3}, "1, 22, 3" is entered in cell A2 the formula becomes
=SUM(SUMIF(A5:A10,A2,E5:E10))
I have tried but get 0 as a result (refer C16)
A B C D E F G H
1 Tree
2 {1,22,3} 1
3 22
4 Tree Profit 3
5 1 105
6 2 96
7 1 105
8 1 75
9 2 76.8
10 1 45
11
12 330 =SUM(SUMIF(A5:A10,{1,22,3},B5:B10))
13
14 330 =SUMPRODUCT(SUMIF(A5:A10,E2:E3,B5:B10))
15
16 0 =SUM(SUMIF(A5:A10,A2,B5:B10))
17 NB: Custom Format "{"#"}" on Cell A2 I enter 1,22,3 so it displays {1,22,3}
Ok so after some further searching (see Excel string to criteria) and trial and error I have come up with the following solution.
Using Name Manager I created UDF called GetList which Refers to:
=EVALUATE(Sheet1!$A$3) NB: Cell A3 has this formula in it =TEXT(A2,"{#}")
I then used the following formula:
=SUMPRODUCT(SUMIF($A$5:$A$12,GetList,$B$5:$B$12))
which gives the desired result of 321 as per the other two formulas (see D12 below).
If anyone can suggest a better solution then feel free to do so.
Thanks to Dennis to my original post regarding table
A B C D E
1 Tree
2 1,22,3 1
3 {1,22,3} =TEXT(A2,"{#}") 22
4 Tree Profit 3
5 11 105
6 22 96
7 1 105
8 3 75
9 2 76.8
10 1 45
11
12 321 =SUMPRODUCT(SUMIF($A$5:$A$12,GetList,$B$5:$B$12))
13
14 321 =SUM(SUMIF(A5:A10,{1,22,3},B5:B10))
15
16 321 =SUMPRODUCT(SUMIF(A5:A10,E2:E3,B5:B10))
17
18 0 =SUM(SUMIF(A5:A10,A2,B5:B10))
19 NB: Custom Format "{"#"}" on Cell A2 I enter 1,22,3 so it displays {1,22,3}

How to copy field in PivotTable

I want to copy a field in the PivotTable summary area. Below is my PivotTable:
Group_Age Sum of attrition_flag Count of acct_id Max of age
1 73 661 27
2 65 663 37
3 54 779 57
4 32 467 59
5 40 725 62
Now if I also want to add Min of age, how do I do that?
Currently I am trying to copy and paste field "Max of age" in the summary area and change the field settings, but I am unable to copy and paste.
Just drag the Age field into Σ VALUES a second time and for this "Summarize value field by" Min.

How to format a number to appear as percentage in Excel

So lets say I have a few numbers in a sheet
a b c d
1 33 53 23 11
2 42 4 83 64
3 75 3 48 38
4 44 0 22 45
5 2 34 76 6
6
7 Total 85
I would like to display those numbers so that the cell value still holds the original figure (A1 = 33)
but the cell displays both the number and a percentage from the total (B7) eg
a b c d
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
I know how to format a cell as a percentage, but I can't figure out how to display both original values, the calculated percentage value (value/total*100), but not change the cell value so I could still sum the cells in the end (eg. A6 =SUM(A1:A5) = 196)
Does anyone have an idea? I was hoping there could be a way to duplicate and calculate the figure using text formatting, but I can't get anything to work.
I'm guessing this is a trivial answer and maybe not what you're looking for, but why not just add a column for each of the columns you have now?
a a' b b' c c' d d'
1 33 (39%) 53 (62%) 23 (27%) 11 (13%)
2 42 (49%) 4 (5%) 83 (98%) 64 (75%)
3 75 (88%) 3 (4%) 48 (56%) 38 (45%)
4 44 (52%) 0 (0%) 22 (26%) 45 (53%)
5 2 (2%) 34 (40%) 76 (89%) 6 (7%)
6
7 Total 85
#Ari’s answer seems to meet to meet the requirements in your question, not repeat information more than the example you gave for output requirement and be viable for up to around 8000 or so columns to start with (unless a very old version of Excel) and Jerry’s comment is also correct that what you want to achieve the way you want to achieve it is not possible.
However there are other approaches that might be acceptable substitutes. One is to copy your data and Paste Special with Operation Divide, either elsewhere or over the top of your data. If over the top this either shows the values or the percentages otherwise duplicates your data. Over the top would also require something like Operation Multiply to revert back to values, and reformatting each time if to appear as in your example.
Another is to use a PivotTable with some calculated fields and both are shown below:
I appreciate neither is exactly what you are asking for.

Excel table formulas to return blank

I have a table in excel with 2 columns, the E column is the running total the D column is the input value so normally it would be = E15+D16 however, i want the E column to return a blank if nothing is entered in the D column- what formula do I need?
1 Nov-23 Nov-30 1,230 1,230
2 Dec-01 Dec-07 130 1,360
3 Dec-08 Dec-14 416 1,776
4 Dec-15 Dec-21 124 1,900
5 Dec-22 Dec-28 102 2,002
6 Dec-29 Jan-04 83 2,085
7 Jan-05 Jan-11 95 2,180
8 Jan-12 Jan-18 88 2,268
9 Jan-19 Jan-25 102 2,370
10 Jan-26 Feb-01 130 2,500
11 Feb-02 Feb-08 311 2,811
12 Feb-09 Feb-15
13
14
15
16
17
18
19
20
21
22
=if(D16="","",E15+D16)
You dont even need the ISBLANK, just use empty quotes.
ISBLANK is what you're looking for.
In E16 =IF(ISBLANK(D16), "", E15+D16)
Use If and IsBlank in conjunction.
Do a check to see if the cell is blank, then depending on the result do the sum or the return blank. I don't have excel in front of me atm, but it should go something like this:
=if(ISBLANK(D16), "", E15+D16)
You can drag this down starting from the second cell in the column where this running total lives. The first one is obviously just the value from the adjacent cell.

Resources