Find count of concurrent items - excel-formula

I have parallel execution of 48 entries and I would like to make a diagram on how many thread Parallel.ForEach ran for me at every time.
I made the debug output seen below, where adjacent start/end lines are from the same thread. For quick result, I went into Excel and put them into column A:
A
61771961 ParallEx starts
61773115 ParallEx ends
61771961 ParallEx starts
61773271 ParallEx ends
61771961 ParallEx starts
61773287 ParallEx ends
61771961 ParallEx starts
61773318 ParallEx ends
Now I used =VALUE(MID(A1; 1; 8)) to get value pairs of the form:
B C
61771961 61773115
61771961 61773271
61771961 61773287
61771961 61773318
...
Then I made into column D the numbers 1..96, and used =SMALL(B$1:C$96;D1) to get the ordered list of time points at which changes to any thread occurred:
D E
1 61771961
2 61771961
3 61771961
4 61771961
5 61772507
6 61773037
7 61773115
8 61773115
9 ...
Then I wanted to find how many threads I had running at every of the interesting time points:
=SUMIFS(B$1:B$96;CONCATENATE(">=";E1);C$1:C$96;CONCATENATE("<=";E1))
but the result is always zero. Where is my error?

Your values in Column C are all Greater than your values in Column E per your examples.
Column C: 61773115 Column E: 61771961
Your sumifs is looking for column be to be less than or equal to Column E which should work fine, but it is also looking for column C to be less than Column E which it is not finding
Hope that helps

Related

Retrieve column 4 from Column 2 and 3 which contains minimum and maximum conditions along with Column 1 which is a separate value?

Hello I have a table shown below where I have letters in column 1, and min and max ranges for column 2 and 3. I am trying to retrieve the final number in column 4.
I know I can use a VLOOKUP and set the range as TRUE to get the last column. However, how would I factor in multiple columns/criteria to find match the correct range with the correct letter.
For example, I can would like to get value 4 from the last column. I would have to match with "B" and it would be between 0 and $50,000.
A 0 $50,000 1
A $50,001 $100,000 2
A $100,001 $250,000 3
B 0 $50,000 4
B $50,001 $100,000 5
B $100,001 $250,000 6
C 0 $50,000 7
C $50,001 $100,000 8
C $100,001 $250,000 9
Thank you!
Two ways:
If the pattern is the same as to the breaks of the dollar amounts then use this:
=INDEX(D:D,MATCH(G1,A:A,0)+MATCH(H1,$B$1:$B$3)-1)
Where MATCH(G1,A:A,0) returns the first row where the ID is located and MATCH(H1,$B$1:$B$3) finds the relative location of the price in the first pattern. Change $B$1:$B$3 to encompass the whole pattern.
If the patterns are different then you can use this:
=SUMIFS(D:D,A:A,G1,B:B,"<=" & H1,C:C,">=" & H1)
One more for the future when Microsoft releases FILTER():
=FILTER(D:D,(A:A=G1)*(B:B<=H1)*(C:C>=H1))
This is entered normally and does not matter the pattern.

Excel formula to apply penalty column to ranking

I have thought long and hard about this, but I can't find a solution to what I believe is quite a simple problem.
I have a table of results, where sometimes someone will be given a penalty of a varying amount. This is entered into the penalty column (Col C).
I need a formula which checks if there is an entry into the penalty column and applies it, not only to that row, but to the number of subsequent rows which are affected, depending on the severity of the penalty.
I have tried to see if this is possible by referencing the penalty against the 'ROW()' function but have not been able to achieve the desired effect.
Col D shows the desired output of the formula.
Col E is included for reference only, to show the desired effect on each row.
Col A Col B Col C Col D Col E
Pos Name Penalty New Pos Change
1 Jack 1 0
2 Matt 2 0
3 Daniel 2 5 +2
4 Gordon 3 -1
5 Phillip 4 -1
6 Günther 6 0
7 Johann 3 10 +3
8 Alain 7 -1
9 John 8 -1
10 Gianmaria 9 -1
The big issue is, if someone is handed a big penalty, for example '10' then it affects the following ten rows. I can't work out how to include this variable logic...
I would be interested to hear the approach of others...
You need to use the RANK() function:
Excel RANK Function Examples
In a new column, add the penalty value to the original position, plus a small coeffieient depending on the original position (0.01 per increment perhaps) to move the penalised player below the original person at that position, then in the next column you can RANK() the new column of values (F in my case).
New value is therefore =A2+(IF(C2>0,C2+(0.01*A2)))
Rank is then =RANK(F2,F2:F11,1)
You can combine all the functions into one, but it's clearer to do it in separate columns at first.

Hierarchical auto-numbering (with three levels) in Excel

What if we have a three-level hierarchy and need to enumerate only "B"s (according to the pattern), but some "C-"s interfere with "B"s.
Problem: to get column B result from a given column A.
A+
B 1
B 2
С-
B 3
A+
B 1
С-
B 2
A+
С-
B 1
B 2
B 3
P.S. The task arose from the need to enumerate complex hierarchy in Excel.
Imagine that A - level 1; B - level 2; C - level 3. (with some abuse of logic in the example above as C- in the pattern goes after A, which in practice is usually not the case).
The simple case of two-level hierarchy is shown here.
Easiest would be to add in two intermediary helper columns, the first of which we'll call column C. Here, we will count only which "A+" we're on, like so [starting at C2; C1 is hardcoded as 1]:
=IF(A2="A+",A1+1,A1)
This will increment every time a new row has "A+" in column A.
Then column D will track the highest # reached so far, for that iteration in column C [starting at D2; D1 is hardcoded at 1]:
=IF(A2="A+",0,if(A2="B",B2,D1))
This will restart at 0 for each new "A+", and for each "B" it will take the value shown in column B. Then for each "C", it will simply repeat the value from the row above (the previous "B" reached).
Finally you can put in your sort, as follows [starting at E1]:
=IF(A1="B",B1,"")
This will show BLANK for either "A+" or "C", and will show the B-count if column A = "B".
I also went with a helper column (as much as I detest them personally) to show the row of each A+
Put this in C1: =ROW(A1)
Put this in C2: =IF(A2="A+",ROW(A2),C1)
It uses an expanding range with a rebasable starting point. Drag down as far as your data goes.
Put this in B2: =IF(OR(A2="C-",A2="A+"),"",IF(A1="A+",1,MAX(INDIRECT("B" & C2 & ":B" & ROW(A1)))+1))
Drag down as far as your data goes.
Hope that helps. Here are the results I received:
A+ 1
B 1 1
B 2 1
C- 1
B 3 1
A+ 6
B 1 6
C- 6
B 2 6
A+ 10
C- 10
B 1 10
B 2 10
B 3 10

Making multiple copies of a cell and duplicating it for a list

I have a list of different names that I would like to duplicate each one by 3 copies of itself. For instance:
A
B
C
D
E
to the following:
A
A
A
B
B
B
C
C
C
D
D
D
E
E
E
How I would I accomplish this in excel? Can it be done in Excel?
There are SOOO many ways to do this... One way would be using something along the lines of the OFFSET() function like so:
Supposing your original list was in cells A1:A5, say. You could then put this formula where you want it:
=OFFSET($A$1,ROUNDDOWN((ROW(A1)-1)/5,0),0)
and drag it down for the 25 rows you want.
In essence, what you're saying is:
Offset cell A1 by ROUNDDOWN((ROW(A1)-1)/5,0) rows and 0 columns.
Looking at that ROUNDDOWN() function:
Row(A1) = 1 (Similarly, Row(A2) = 2, etc...
(Row(A1)-1) / 5 = 0/5 ; 1/5 ; 2/5 ; .....
Rounddowwn(...) means 0/5 to 4/5 becomes 0 ; 5/5 to 9/5 becomes 1 ; etc
Therefore, it will offset A1 by 0 rows and 0 columns 5 times then by 1 row and 0 columns for the next 5, etc.
Hope that makes sense :)
EDIT:
The original question asked for 3 copies of each value, not 5 - I'm leaving the answer as-is purposefully with this edit so someone else can see how to change it to any number of repetitions as wanted... All that would change would be:
=OFFSET($A$1,ROUNDDOWN((ROW(A1)-1)/3,0),0)
Simply, divide by 3 rather than 5 for that to occur...

How to align and merge matching values, from various columns, in excel

I have had some success matching data from various columns and creating a new data output. Here is what I typically start with;
COL A COL B COL C COL D
ITEM VALUE ITEM VALUE2
---- ---- ---- ----
A 1 B 100
B 2 A 200
C 3 F 300
G 4 E 400
H 5 C 500
J 6 M 600
And I can achieve this result using VLOOKUP;
COL E COL F COL G
ITEM VALUE VALUE2
---- ---- ----
A 1 200
B 2 100
C 3 500
G 4
H 5
J 6
But what I'm really after is this: both matching AND merging;
COL E COL F COL G
ITEM VALUE VALUE2
---- ---- ----
A 1 200
B 2 100
C 3 500
E 400
F 300
G 4
H 5
J 6
M 600
I'm punching a tad above my weight class with this one, so any help would be greatly appreciated.
With something like:
=COUNTIF(A:A,C2)
in a column and copied down you should get indication of which items are not already present in ColumnA. Sort with C:D on that basis and simply copy the items associated with 0 to ColumnA and their values to ColumnD, then sort and apply your VLOOKUP.
The following is based on: http://www.get-digital-help.com/2009/05/25/create-a-drop-down-list-containing-only-unique-distinct-alphabetically-sorted-text-values-using-excel-array-formula/#comment-74005
It's a great site for clever use of Excel formulas and does a good job of explaining the monster formulas below, creating dynamic named ranges, and how to work with array formulas. Look at it!
My solution is not quite as elegant as I'd like but it works. So, you'll need to create some named ranges.
One for the items in COL A (e.g. "Items1") and one for the items in COL C (e.g. "Items2")
In COL G we'll have another List "AllItems1". In COL H we'll have another List "AllItems2". You'll need to make a named range of "AllItems1" too.
The array formula in COL G is:
=IFERROR(IFERROR(INDEX(Items1,MATCH(0,IF(MAX(NOT(COUNTIF($G$1:$G1,Items1))* COUNTIF(Items1,">"&Items1)+1))=(COUNTIF(Items1,">"&Items1)+1),0,1),0)),INDEX(Items2,MATCH(0,IF(MAX(NOT(COUNTIF($G$1:$G1,Items2))*(COUNTIF(Items2,">"&Items2)+1))=(COUNTIF(Items2,">"&Items2)+1),0,1),0))),"")
Which is a mouthful. This cascades through each list (i.e. Items1 and Items2) and gives you a non-repetitive sorta alphabetized list of the items in "Items1" and "Items2".
COL G is really just an intermediate step to get us to COL H. I haven't found a way to combine two lists without doing this step. Let me know if you find a better way.
To get a non-repetitive AND alphabetized list of the items we put the following array formula in COL H:
=IFERROR(INDEX(AllItems1,MATCH(0,IF(MAX(NOT(COUNTIF($H$1:$H1,AllItems1))*(COUNTIF(AllItems1,">"&AllItems1)+1))=(COUNTIF(AllItems1,">"&AllItems1)+1),0,1),0)),"")
Then we do VLOOKUP s off of "AllItems2".
Put the following VLOOKUP in COL I :
=IFERROR(VLOOKUP($H2,$A$2:$B$7,2,0),"")
And put the following VLOOKUP in COL J:
=IFERROR(VLOOKUP($H2,$C$2:$D$7,2,0),"")
Of course, you could make "AllItems2" a named range also and use that in the VLOOKUP s.
I think that gets you what you want.

Resources