How to rank multiple columns on excel. I'm using Microsoft Office Professional Plus 2016 [closed] - excel

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I have the following input data:
Contamination
10%
10%
20%
20%
30%
30%
Estimator
Trial 1
Trial 2
Trial 1
Trial 2
Trial 1
Trial 2
OLA
500
75
100
430
460
230
PWA
360
457
400
200
200
400
CA
470
270
450
250
350
150
HA
215
310
200
400
400
200
AM
300
500
315
200
500
250
Table has 5 different estimators each having 2 repeated trials for each of the 3 groups of percentages of contaminations (10%, 20%, and 30%) considered.
For each of the 5 estimators (in my real problem I have more than 5), I want to rank (from lower to highest value) among the trials within each group of percentages (in my real problem I have more than 3) simultaneously.
I am looking for a solution, that doesn't require manually to rank each group, since in my real problem I have a larger group of percentages, trials per group and experiments. The number of trials within each group are the same.
I want to get a formula that can rank it simultaneously. Here is the expected output from the input data sample:
Contamination
10%
10%
20%
20%
30%
30%
Estimator
Trial 1
Trial 2
Trial 1
Trial 2
Trial 1
Trial 2
OLA
2
1
1
2
2
1
PWA
1
2
2
1
1
2
CA
2
1
2
1
2
1
HA
1
2
1
2
2
1
AM
1
2
2
1
2
1
Notes:
I have an older version of Excel: Microsoft Office Professional Plus 2016, please consider that in your answer
The Contamination is the same within the trial set (Trial 1, Trial 2). Table Markdown feature doesn't allow to merge cells, that is why the percentage is repeated

I assume from your question:
I do not want to rank them individually as it will take much time
since I have more than 50 of them to rank
You are referring to the percentage groups and/or number of trials that can be large, which is the most difficult task to expand.
In the cell L3(see screenshot below) I put the first formula that can be expanded vertically and horizontally. Please pay attention to the $ mark to ensure it works in both directions.
=RANK(OFFSET($C3,0, L$2*$J$2 + L$1),
OFFSET($C3,0, L$2*$J$2,1,$J$2),1)
Using named ranges, for example naming $J$2 as totalTrials it is easier to understand the formula:
=RANK(OFFSET($C3,0, L$2*$totalTrials + L$1),
OFFSET($C3,0, L$2*totalTrials,1,totalTrials),1)
or even better, using the modern LET function to define all the variables first, is the easiest way to read it:
=LET(startCell,$C3, totalTrials,$J$2,
groupCnt, L$2*totalTrials, trialCnt,L$1,
RANK(OFFSET(startCell,0, groupCnt + trialCnt),
OFFSET(startCell,0, groupCnt,1,totalTrials),1)
)
and here is the output:
Changing the values of Trial per Group (J2) or # Groups (J4) and expanding the formula horizontally and vertically you can consider a large number of trials within the group, large number of groups and a large number of experiments.
Explanation
For doing the ranking per experiment within the group I use the RANK(number,ref,order). For jumping from one group to another and getting the specific trial within the group, the OFFSET(reference, rows, cols, height, width) function. (check this link for more information about OFFSET function).
For building the recurrence in the formula I use the following two helper rows:
L1:Q1: The trial number within the group, starting from zero, via the following formula: MOD((COLUMNS($A$1:A1)-1),$J$2). It generates the sequence: 0,1,2,...N, 0,1,2,..N, where N is the number of trials minus one (easier to start from zero for the recurrence). In the sample the number of trials is indicated in the cell: J2.
L2:Q2: The group number, starting from zero, that each trial belongs to via the following formula: INT((COLUMNS($A$1:A1)-1)/($J$2)). It generates the sequence: 0,0,0,..0, 1,1,1,..1,...M,M,M...M, where each number is repeated as many times as trials we have where M is the number of groups minus one.
Note: There is a more concise way for building such sequences in modern excel versions via SEQUENCE but you indicated you have an older version.
In order to generate both sequences, I took the idea from here: Excel Magic Trick 692: More About Incrementing Numbers In Formulas (that works for older excel versions)
Combining properly both helper rows in OFFSET, the rank is calculated per trial per experiment.
This explanatory picture from ExcelJet, helps to understand each input argument of the OFFSET function:

Related

Excel - Add figures dependending on the results of other cells

It may be that I have tried to use the correct formula, but have misused it but so far I haven't found anything that seems to be working for me.
I have 6 individual conditions, that when each is met there is a % attributed to that item that I want to be returned. At times none of these conditions may be met, at other times all may be met, so I will get anywhere from 0% to 100% as possible return values. Everytime I want each of the true values to be added together to give me the sum of these, and the false values to give me nothing.
It is essentially that if there is income for each item, there is a known % of the total budgeted service costs that will then be required, and to be able to best estimate the costs associated with each level of income as it may change until at 100% I want to be able to put this in to a formula.
So on the below for example in Jan, the % to be returned should be 89%, as only Item 5 did not see any income
Month Jan Feb Mar
% Item Income Income Income
13% 1 400 134 397
20% 2 411 - 14
21% 3 200 127 231
23% 4 84 127 -
11% 5 - 427 218
11% 6 4 5 320
I have attempted to use multiple ways with it ending in sumifs and countifs, maybe I was putting them together wrong but I wasn't able to get the desired result. The - it was also not picking up as a 0 value, the format is currency, but to be check if there is income I am simply going with if the income foe this item, in this month is >0 then return the %
Jack,
Welcome to SO!
The formula you want is: =SUMIF(C3:C8,">0",$A$3:$A$8)
If you just enter a minus sign, it will be treated as a single-character string rather than a number, so if you want to test for inequality or equality you have to compare it against a string:
=SUMIF(C3:C8,"<>-",$A3:$A8)
or
=1-SUMIF(C3:C8,"-",$A3:$A8)
(I suspect that there may be additional decimal places that we can't see to explain the discrepancy between the results with these two formulas).

Finding stabilizing average of agent-based model runs

So I ran about 200 agent-based model runs and I want to see how the average is changing over time.
For example if we have 10 points
2 4 2 8 6 5 9 8 1 3
I want to calculate the average as the number of points changes
(2+4)/ 2 = 3
now for the next point it will be (3+2)/2 = 2.5
so I can plot each average and see after how many runs does the average stabilize. Something like this image < https://imgur.com/a/VXeeuxy > Can someone provide an equation or method?
Thank you
I think you just want a 'cumulative average' of 1,2..n points. You can do this in a single formula if you don't mind using offset:
In most versions of Excel (F1):
=SUBTOTAL(1,OFFSET(B23,0,0,1,COLUMN(B23:K23)-COLUMN(A23)))
In Excel 365 only (F2):
=SUBTOTAL(1,OFFSET(B23,0,0,1,SEQUENCE(1,COLUMNS(B23:K23))))
Or a more dynamic version that works for a whole row (F3):
=SUBTOTAL(1,OFFSET(B23,0,0,1,COLUMN(A1:INDEX(1:1,COUNT(23:23)))))
and (F4)
=SUBTOTAL(1,OFFSET(B23,0,0,1,SEQUENCE(1,COUNT(23:23))))

Excel how to distribute 2 percentage fields between 3 fields

I'm having a difficulty to figure out how to distribute 2 percentages fields in 3.
Let's say we have 2 teams. I think they both have chances 50/50 means that the draw has the percent of 50, 25 for the first team and 25 for the second team. So i'm stuck in finding the formula to calculate Draw chances.
Another example, if i believe that first team win percent is 70% and second team win is 30%. What would be the % for the draw?
I have tried to divide each team % by 3 and multiply by 2, then deduct sum of these results from 100%, but obviously, in every case I get 33% for the draw. For example I get 33% for the draw in case if chances of both teams are 50/50, instead of 50 for the draw, 25 for first team and 25 for the second team.
Thank you!

count how often a piece of information appears and calculate that average

I do not want to know the traditional frequency or the traditional averages; so I'll give an example below:
I have this data:
1
3
5
5
2
3
5
5
1
3
The analysis that I would like to obtain is the following:
for example number 1 appears once every eight rows, number 3 appears once every four rows, number 5 appears twice every two rows....
I did it by hand, but now I have more than 21000 rows of data and I'm stuck.
I searched but I can not find a function that does it; But before I started developing my own, I decided to ask for a guide on how to achieve it.
I believe that I was able to achieve the desired result:
The formula is:
Or, if you want to copy/paste:
=IF(CONCATENATE("1-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+1,1,4)&":A17"),0))="1-1",CONCATENATE("2-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+2,1,4)&":A17"),0)-1),CONCATENATE("1-",MATCH(D1,INDIRECT(ADDRESS(MATCH(D1,A1:A17,0)+1,1,4)&":A17"),0)))
Note that the IF function solves the duplicates (like the number 5). In case you have triplicates you will have to add another instance of IF and adjust the formula accordingly.
Hope that helps!
Well this doesn't exactly reproduce your results, but you could start by looking at the max and min separation of the numbers:
=IF(COUNTIF(A$1:A$10,C2)<=1,"",MIN(IF((ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))>1)
*(ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))<=COUNTIF(A$1:A$10,C2)),
FREQUENCY(IF(A$1:A$10<>C2,ROW(A$1:A$10)),IF(A$1:A$10=C2,ROW(A$1:A$10)))))+1)
=IF(COUNTIF(A$1:A$10,C2)<=1,"",MAX(IF((ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))>1)
*(ROW(A$1:INDEX(A$1:A$10,COUNTIF(A$1:A$10,C2)+1))<=COUNTIF(A$1:A$10,C2)),
FREQUENCY(IF(A$1:A$10<>C2,ROW(A$1:A$10)),IF(A$1:A$10=C2,ROW(A$1:A$10)))))+1)
This gives the min or max number of rows between each occurrence of the particular number.
Must be entered as an array formula using CtrlShiftEnter
You could add other statistics (like mean, standard deviation) the same way although the average could be calculated just by (lastrow-firstrow)/(count-1) e.g. for 5 it would be (8-3)/(4-1)=5/3.

Excel Solver solver is messing up my optimization

I have set up an optimization problem but i must be doing something wrong and I could use your help. I have three firms: alpha, Bravo, Charlie. They each complete three tasks: Milling, Inspecting, Drilling. They each require different amounts of minutes to complete each task. Alpha requires 12 minutes to mill, 5 minutes to inspect and 10 minutes to drill. Bravo requires 10 minutes to mill, 4 to inspect, and 8 to drill. Charlie requires 8 to mill, 4 to inspect, and 16 to drill. After each firm completes all of these tasks they will earn a certain amount of profit, Alpha will earn $2.40, Bravo will earn $2.50, and Charlie will earn $3.00. All three firms have a maximum allotted time of 1200 minutes to mill, 900 to inspect, and 1440 to drill. The goal is to maximize the profit of these three firms. I have set it up so that the sums of the tasks will take away from the available time left when changed by the solver. I have also set constraints within the solver to cap each task to the allotted time allowed per task. I must be missing a vital step however because it keeps trying to just max out the allotted time for an individual firm, not taking in to account the opportunity cost of the other firms or something. Please help! (shown in photos)
Data
Solver
After executing Solver
I have changed the logic a bit different in order to take the minimum unit into consideration:
UNITS portion are the variable cells. Since the final produced unit will be the minimum of these cells, E9 formula is =MIN(B9:D9) and copied down.
TIME portion is multiplication of Unit Times and Units. So the formula of B14 is =B9*B2 and copied down & right.
I9:I11 are the earnings calculated by multiplying the unit earning with the minimum units
I12 is our total earning and is our Objective cell.
Please also be careful about the constraints since when you do not set an integer constrain, finding a solution becomes more difficult and of course our units should be integer in any case.
And also fill B9:D11 cells with some values such as 100, since otherwise iteration does not start correctly and solver ends up with a very small objective cell.
I have just had a go at this and I get a different answer as I have made the assumption that to achieve the profit the company must complete a milling process, then inspect, then drill and once all are complete then that is 1 unit for the profit - I hope that is valid.
But if not, then this layout may help you anyway. Note I have set this as a Linear model for the solver and also note the use of integer and non-negative.
It was fun anyway !

Resources