I have a list of products ranked by percentile. I want to be able to retrieve the first value less than a specific percentile.
Product Orders Percentile Current Value Should Be
Apples 192 100.00% 29 29
Apples 185 97.62% 29 29
Apples 125 95.24% 29 29
Apples 122 92.86% 29 29
Apples 120 90.48% 29 29
Apples 90 88.10% 29 29
Apples 30 85.71% 29 29
Apples 29 83.33% 29 29
Apples 27 80.95% 29 29
Apples 25 78.57% 29 29
Apples 25 78.57% 29 29
Apples 25 78.57% 29 29
Oranges 2 100.00% 0 1
Oranges 2 100.00% 0 1
Oranges 1 60.00% 0 1
Oranges 1 60.00% 0 1
Lemons 11 100.00% 0 2
Lemons 10 88.89% 0 2
Lemons 2 77.78% 0 2
Lemons 2 77.78% 0 2
Lemons 1 55.56% 0 2
Currently my formula in the "Current Value" column is: =SUMIFS([Orders],[Product],[#[Product]],[Percentile],INDEX([Percentile],MATCH(FALSE,[Percentile]>$O$1,0))) (entered as an array formula)
$O$1 contains the percentile that I am matching (85.00%).
The current value for "Apples" (29) is correct, but as you can see my formula is not producing the correct value for the remaining products as in "Should Be" but is returning "0". Not sure how to set this up to get it to do what I need it to. I tried several things with SumProduct but couldn't get that to work either. I need someone with more experience to give me a hand on this.
You don't need the SUMIFS(), just the INDEX/MATCH:
=INDEX([Orders],MATCH(1,([Percentile]<$O$1)*([Product]=[#Product]),0))
This is an array formula and must be confirmed with Ctrl-Shift-Enter on exiting edit mode. If done properly then Excel will put {} around the formula.
Related
Most of the SUMIFS criteria seems to work the way I want it to work, except the years criteria does not.
It seems that once 2028 is recognised in column “DO” (years) it will continue to SUM (even if the year is not 2028). Does anyone have any suggestions?
=IF(AB3=0,0,SUMIFS($I$3:$I3,$B$3:$B3,B3,$AB$3:$AB3,">0",$DO$3:$DO3,$DG$8))
The $DG$8 cell reference is: 2028
AB (use or not to use)
I (tons)
B (group)
DO (year)
What I want
1
200
2
2028
200
0
200
2
2028
0
1
210
2
2028
410
1
240
2
2025
0
1
50
2
2024
0
1
200
3
2028
200
1
210
3
2025
0
1
240
3
2028
440
1
50
3
2024
0
0
240
3
2028
0
You can use AND() to check if "Year" is 2028 beforehand if you wish to keep these rows at zero:
Formula in G2:
=IF(AND(A2,D2=2028),SUMIFS(B$2:B2,A$2:A2,1,C$2:C2,C2,D$2:D2,2028),0)
Currently, I have this dataframe in pandas:
year product
8 2016 apples
15 2016 kiwis
17 2016 mango
24 2016 mango
32 2016 mango
34 2016 peach
41 2017 peach
45 2017 peach
48 2017 peach
53 2017 bananas
54 2017 mango
72 2017 peach
73 2017 peach
I've been trying with melt and pivot, but alas no luck. Basically I want to count the instances of products I sold each year. What I want as dataframe is this:
apples peach bananas kiwi mango
2016 1 1 0 1 3
2017 0 5 1 0 1
How can i reshape my df to the desired outcome?
Try:
df1 = df.groupby(['year', 'product']).size().unstack(1, fill_value=0)
print(df1)
product apples bananas kiwis mango peach
year
2016 1 0 1 3 1
2017 0 1 0 1 5
Or like mentioned in the comments:
pd.crosstab(df['year'], df['product'])
I'm trying to create a dynamic rolling 12 month cash flow in Excel.
Lets say the month name is in cell A1.
Underneath cell A1 l have a list of cash flow expenses in my rows and the expenses listed in the columns by month. I have a separate column at the end that totals up 12 months of expenses based on the month name (in cell A1).
So, if cell A1 says Jun-18, l want to add up the expenses for each row item from Jun-18 to May-19. OR say, if cell A1 says Sep-18, l want to add up the expenses for each row item from Sep-18 to Aug-19.
I don't know how to do this, can anyone please advise.
Thanks for your help,
M
You can use sum ofset match
Given the example data below (as I think that you have described in your question), you can use the the following formula (this example the formula result is showing in B2) A1 contains the start date to calculate from.
=SUM(OFFSET(A2,MATCH(A1,A2:A100)-1,4,12,1))
You will need to research how ofset works, as I currently do not have time to explain, but to help you use this formula within your worksheet you will need to change the number 4 which is 4th column away (column E containing the months totals) from the matched date.
The 12 in the formula shows how many rows down you want to sum.
A B C D E
1 Jul-18 8638.21
2 Expence1 Expence2 Expence3 Total
3 Jan-18 1 1 1 3
4 Feb-18 2 2 2 6
5 Mar-18 3541 531 51 4123
6 May-18 100000 31 351 100382
7 Jun-18 846 8 321 1175
8 Jul-18 1 153 12 166
9 Aug-18 0 8 21 29
10 Sep-18 0 65 8 73
11 Oct-18 54 321 1 376
12 Nov-18 321 123 1 445
13 Dec-18 1 321 2 324
14 Jan-19 546 0 51 597
15 Feb-19 132 51 15 198
16 Mar-19 12 321 51 384
17 Apr-19 51 123 321 495
18 May-19 5161 3.21 351 5515.21
19 Jun-19 21 3 12 36
20 Jul-19 321 1 1351 1673
I have below table
Month LoB Score Rank
Jan A 1
Jan B 2
Feb B 1
Feb B 2
Jan A 2
Mar C 1
Feb A 3
Jan A 3
Mar C 2
Mar A 1
Mar C 3
I want to Rank the scores basis Month and LoB. For ex in Jan for A whatever is highest will get Rank 1. Similarly in Jan for LoB B whatever is highest will get Rank 1.
I understand that Index and Row formula are to be used in conjunction with Rank.eq but i am unable to put it together at all. I would appreciate any help on this.
Thank you
Assuming Row1 is the header row and actual data lies in the range A2:C11, then try this...
In D2
=SUMPRODUCT(($A$2:$A$11=A2)*($B$2:$B$11=B2)*($C$2:$C$11>C2))+1
and copy it down.
AoA / Good morning
by using Rank formula problems face in correct position.=RANK(K5,K5:K34)
Marks Position total marks 350
obtained
290 29
346 9 (student obtained 346 marks how he have 9th position he must be 4th position)
250 30
343 20
345 13
342 21
334 26
346 9
345 13
346 9
346 9
348 5
350 1
349 3
335 24
345 13
335 24
348 5
339 22
295 28
350 1
345 13
348 5
344 18
345 13
338 23
347 2
349 3
297 27
I have an excel with:
Days of the week and 24 hours for each day.
Each hour I get some points.
I would like to calcute the maximum of cumulate points I can get within 24 hours.
[TEST.XLSX]
2 Columns:
Monday Points
0 34
1 32
2 4
3 54
4 12
5 55
6 4
7 4
8 555
9 787
10 8
11 76
12 78
13 8
14 656
15 7
16 4
17 45
18 54
19 543
20 56
21 65
22 4
23 3
Tuesday
0 56
1 7
2 333
3 9
4 876
5 3333
6 3333
7 76
8 3333
9 465
10 7
11 6
12 5
13 6
14 7
15 6
16 7
17 65
18 555555555
19 6
20 5
21 4
22 6
23 6
Wednesday
0 6
1 7
...
Thanks for your help!
Use real date time values in your hours column. Delete the rows with the day text. Instead, use a formula that increments from a starting date/time. For example: cell A2 contains the date and midnight time for Nov 17. Cell A3 and copied down contains the formula
=A2+TIME(1,0,0)
which increments by one hour.
Now you con build a pivot table. Group by the date/time value by day and hour. Show the subtotal for the day and set its value field settings to Max.