I saw the following question on here regarding repeating values:
List number of lessons including half lessons based on Number of lessons and lesson name
This question needed an older Excel version, I liked the problem statement and liked searching for a solution including new Excel formulas.
We have the following data:
A
B
1
1
w
2
5
e
3
4.5
o
4
2.5
Win
5
1.5
pp
The idea is to repeat the value of column B the number of times mentioned in column A.
The challenge is that column A could also contain non-integers (0.5-values only).
If a 0.5-value is used it should repeat the value in column B the number of integers in A and show 0.5 and the text value stacked with 0.5 and the next text value.
In this case the expected result would be:
expected
w
e
e
e
e
e
o
o
o
o
0.5 o, 0.5 Win
Win
Win
pp
0.5 pp
I managed to get a working solution in Office 365:
=LET(
data,A1:B5,
A,INDEX(data,,1),
B,INDEX(data,,2),
s,SCAN(0,A,LAMBDA(a,b,a+b)),
si,INT(s),
sr,ROUNDUP(s,0),
sm,SEQUENCE(MAX(sr)),
mr,XMATCH(sm,sr,1),
mi,XMATCH(sm,si,1),
IFERROR(
IF(mr=mi,
INDEX(B,mr,),
"0.5 "&INDEX(B,mr,)&", 0.5 "&INDEX(B,mi)),
"0.5 "&INDEX(B,mr,)))
and Tony got an answer using FILTERXML coming real close in the original question:
=FILTERXML(REPLACE(CONCAT(REPT("</c><c>" & B2:B6,FLOOR(A2:A6,1)) & IF(A2:A6-INT(A2:A6)>0,"</c><c>" & A2:A6-INT(A2:A6) & B2:B6,"")),2,2,"p")&"</c></p>","//c")
Would this be realisable in Excel 2013?
I have definitely lost touch with these long-dreaded formulas in previous versions of Excel. So unfortunate CONCAT() is not available for example. Either way, I think the following could work:
Formula in C2:
=IF(COUNTIF(C$1:C1,INDEX(B$1:B$5,IFERROR(MATCH(ROW(A1)-1,MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),ROUND(A$1:A$5,0)))+1,1)))+0.5=INDEX(A$1:A$5,MATCH(INDEX(B$1:B$5,IFERROR(MATCH(ROW(A1)-1,MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),ROUND(A$1:A$5,0)))+1,1)),B$1:B$5,0)),"0.5 ","")&INDEX(B$1:B$5,IFERROR(MATCH(ROW(A1)-1,MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),ROUND(A$1:A$5,0)))+1,1))
Obviously the above is an array-entered formula and needs to be dragged down.
For ms365 users, try:
=DROP(REDUCE(0,REPT(B1:B5&"|",A1:A5)&REPT("0.5 "&B1:B5,MOD(A1:A5,1)>0),LAMBDA(a,b,VSTACK(a,TEXTSPLIT(b,,"|",1)))),1)
Based on a little trick to stack output while running REDUCE(). See here
I managed to get a working version:
=IF(ROW()>CEILING(SUM($A$1:$A$5),1),
"",
IFERROR(IF(
INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(CEILING(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5),1)),
0))
=INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(INT(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5))),
0)),
INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(CEILING(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5),1)),
0)),
"0.5 "&INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(CEILING(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5),1)),
0))
&", 0.5 "&INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(INT(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5))),
0))),
"0.5 "&INDEX($B$1:$B$5,
MATCH(TRUE,
ROW()<=TRANSPOSE(CEILING(MMULT(IF(ROW(A$1:A$5)>=TRANSPOSE(ROW(A$1:A$5))=TRUE,1,0),A$1:A$5),1)),
0))))
Needless to say this is an array-formula and requires being entered with ctrl+shift+enter
Related
I'm not sure if I'm over complicating this...
basically I'd like to have a formula which is
if the c column is less than 6, then look up the max value in B but display the value of C
so far I have this but I'd like it to show 2, not 437
{=MAX(IF(C2:C12<6,B2:B12, 0))}
any advice is appreciated. i'm shy, be nice..thanks
A B C
cat 110 3
dog 148 4
rooster 36 7
duck 32 8
pig 437 2
horse 44 6
eagle 215 5
dolphin 21 1
panda 2 9
iguana 257 10
fish 199 11
edit:
maybe something like
{=INDEX(C2:C12,MATCH(MAX(IF(C2:C12<6,C2:C12)),C2:C12,0))}
but I don't see where to put b2:b12
You really need two conditions
1) Column B is equal to =MAX(IF(C2:C12<6,B2:B12))
2) Column C is <6
so you can INDEX column C when those two are met, i.e.
=INDEX(C2:C12,MATCH(1,(B2:B12=MAX(IF(C2:C12<6,B2:B12)))*(C2:C12<6),0))
confirmed with CTRL+SHIFT+ENTER
{=IF(C2<6,INDEX($C$2:$C$12,MATCH(MAX($B$2:$B$12),$B$2:$B$12,0)),0)}
You were almost there..
Basically if C<6 , find max of B , lookup it in B:C and display corresponding C
{=IFERROR(VLOOKUP(MAX(IF(C2:C12<6,B2:B12, 0)),B2:C12,2,FALSE),0)}
Since your question doesn't clarify what if c>=6 I assume you don't want value.
Can answer more precisely if you clarify.
Mark this as answer if that's correct.
Hope this helps!
As I could see you requested a single INDEX formula:
{=INDEX($C$2:$C$12,MATCH(MAX(IF($C$2:$C$12<6,$B$2:$B$12,0),0),IF($C$2:$C$12<6,$B$2:$B$12,0),0))}
This is an array formula, hit Ctrl+Shift+Enter while still in the formula bar.
Lets break this down.
=INDEX(C:C, - Index column C as these are the values you want returned
MATCH(IF(C:C<6,B:B,0), - Find the largest value from the following array in the array and return it's relative position for INDEX()
IF(C:C<6,B:B,0),0)) - If the value in column c is less than 6 then add the column B value to the array, otherwise add 0
I have a column with numbers and a reference column. I'm trying to separate the numbers column into first third, second third, and last third and take the average of each.
Values Ref column
1.7 cow
2.3 cow
2.6 cow
1.8 sheep
1.3 sheep
2.2 sheep
1.5 sheep
1.2 sheep
2.3 sheep
1.5 goose
2.5 goose
So, for example, the average of the first two values for "sheep", second two, and last two. In other words, I want to take the average of each 1/3 of cells adjacent to "sheep".
Add a column to cumulatively count the instances of the word you're looking at, then check that row number in your AVERAGE.
C2 = =CountIf($B$2:$B2, $B2) and fill down => values should be {1,2,3,1,2,3,4,5,6,1,2}
E1 = sheep
E2 = =CountIf($B:$B, $E$1) => 6
E3 = {=Average(If(($B:$B = $E$1) * ($C:$C <= $E$2 / 3), $A:$A))} (note this is an array formula, as designated by the {} around it) => 1.55
E3 = {=Average(If(($B:$B = $E$1) * ($C:$C > $E$2 / 3) * ($C:$C <= 2 * $E$2 / 3), $A:$A))} => 1.85
E3 = {=Average(If(($B:$B = $E$1) * ($C:$C > 2 * $E$2 / 3), $A:$A))} => 1.75
Array formulas, if I remember correctly, are entered the same as normal formulas (don't include the {}, that gets entered automatically), but you press Ctrl (and possibly Shift) with Enter when you finish.
NB - these look at the entire column. You can speed them up by changing $A:$A to $A$2:$A$12 (likewise for $B:$B and $C:$C). Just bear in mind that for any data you append to this list, you'll need to update the formulas; but you can insert data into the middle of the list and it will update them automatically.
use a formula like this:
=AVERAGE(INDEX(A:A,MATCH($D$2,B:B,0)+(D3-1)*COUNTIF(B:B,$D$2)/3):INDEX(A:A,MATCH($D$2,B:B,0)+((D3)*COUNTIF(B:B,$D$2)/3)-1))
This does require that the ref column be sorted and like references grouped.
This array formula will return the averages even if not sorted:
=AVERAGE(INDEX(INDEX(A:A,N(IF({1},MODE.MULT(IF($B$1:$B$12=$D$2,ROW($A$1:$A$12)*{1,1}))))),N(IF({1},ROW(INDEX(A:A,1+(D3-1)*COUNTIF(B:B,$D$2)/3):INDEX(A:A,D3*COUNTIF(B:B,$D$2)/3))))))
array formula need to be entered with Ctrl-Shift-enter instead of Enter when exiting edit mode.
Well supposing there were 7 sheep values and you wanted to do a weighted mean (e.g. the first mean would be calculated from the first two sheep plus a third of the third one)?
I have attempted a general solution for this dividing any number of animals into any number of fractions and finding their average values. My approach is to use the elegant overlap formula from #Barry Houdini as used here and work out the overlap between the intervals (in the case of 7 animals divided into 3):
0 to 2.33
2.33 to 4.67
4.67 to 7
and the numbers of the animals
0 to 1
1 to 2
2 to 3
and so on.
In H4
=IF(ROWS($1:1)<=$H$2,ROWS($1:1)/$H$2*COUNTIF(B$2:B$16,$G$2),"")
In G4
=IF(H4="","",H4-COUNTIF(B$2:B$16,$G$2)/$H$2)
The main formula in I4 is
=IF(H4="","",SUM(TEXT(IF(C$2:C$16<H4,C$2:C$16,H4)-IF((C$2:C$16-1)>G4,C$2:C$16-1,G4),"general;\0")
*A$2:A$16*(B$2:B$16=$G$2))/(COUNTIF(B$2:B$16,$G$2)/$H$2))
entered as an array formula.
The fractions can be changed to halves, quarters etc. by changing the number in H2.
I'm tracking something extremely simple; a week number, and body weight.
I can't get Excel or Google Sheets to use either of those functions to predict what the weight will be for the next 4 weeks.
I have a chart like this
1 185
2 184.3
3 186
4 189
5 183
6 186
7 188
etc
I need a prediction of 8, 9, 10, 11.
I've tried =FORECAST(X57,Y53:Y56,X53:X56) where the x57 is the next week number, but what happens is Excel/sheets starts counting at a lower number than the last weight. I got a weird negative number with TREND. I know I'm not doing something right. I tried switching the ranges too.
I've inserted a screenshot from Sheets.
I feel really stupid because I should be able to figure this out but it's been over an hour of scratching my head and getting frustrated. I don't have Excel 2016 with the Forecast graph function.
Am I doing this right, but because the numbers go up and down this is Excel/Sheet's best guess?
I placed your data in G1 through H7:
2nd Order Polynomial Trendline
Equation: y = (A * x2) + (B * x ) + C
A =INDEX(LINEST(y,x^{1,2}),1)
B =INDEX(LINEST(y,x^{1,2}),1,2)
C =INDEX(LINEST(y,x^{1,2}),1,3)
So in I1 through I3, enter these equations for the coefficients A, B and C:
=INDEX(LINEST(H1:H7,G1:G7^{1,2}),1)
=INDEX(LINEST(H1:H7,G1:G7^{1,2}),1,2)
=INDEX(LINEST(H1:H7,G1:G7^{1,2}),1,3)
Then enter 8 through 11 in column G. Then H8 enter:
=$I$1*G8^2+$I$2*G8+$I$3
and copy down:
With the data in A1:B7 you could either chart that, set a trendline (linear seems reasonable) and pick up the formula from the chart:
=0.3357*(A1)+184.56
(in C1 and copied down for comparison) or apply this in B8 and copy down:
=FORECAST(A8,B$1:B$7,A$1:A$7)
The known points are used for the chart on the left and the known points plus FORECAST ones for the chart on the right:
I know you don't have Excel 2016, but here is how it would look if you insert a forecast from Excel's Data menu.
Select the cells and then click Data > Forecast Sheet. Change the Forecast End to 11. I left the Options at the defaults as displayed.
Next click Create and you will see the formulas for the forecast and the data in an Excel Table. You can inspect the FORECAST functions used, for example in column C:
=FORECAST.ETS(A9,$B$2:$B$8,$A$2:$A$8,1,1)
Paging All Excel Wizards,
I am trying to see if there is a way to have a one-line SUMIF or something similar to sum up the following criteria in an Excel spreadsheet:
Sum the values of Column C if
If Column A = "Chizzle"
AND If Column B is >= Column B of the next row
Sample Data:
A B C
Type Level Value
__________________
Chizzle 1 23
Chizzle 2 10
Bobbles 3 1.5
Bobbles 3 2.6
Chizzle 2 5.5 <- Should Be counted
Cobbles 2 1
Chizzle 1 3.3 <- Should Be counted
I have tried using something like this:
=SUMIFS(C1:C1000,A1:A1000,"Chizzle", B1:B1000, ">=" & B2:B1001 )
Unfortunately the B2:B1001 part isn't working and it is selecting all values.
If there is a way to do this with a one line calculation, without having to add an additional column? That would be awesome but I'm not sure if it is possible.
Thanks!
Try this SUMPRODUCT():
=SUMPRODUCT(($A$2:$A$8="Chizzle")*($B$2:$B$8>=$B$3:$B$9)*($C$2:$C$8))
A B C
1 10/1/2009 3652449 12:15:43 AM
2 10/1/2009 3652449 12:17:03 AM
3 10/4/2009 3652449 1:03:08 AM
Hello,
I want to sum the total time of the card 3652449 just for 10/1/2009.
Then after the sum is compete I need the time to be converted and rounded into minutes only.
I have been using the following formula till now " =SUMIF(B:B,3652449,C:C) " and the result is " 1:35:54 ". But as I have written I want to sum the time for that card only on the date of 10/1/2009. When you copy the data in excel and you manually sum the time from 10/1/2009 you should get 32m & 46s. When you round it the result should be 32m.
I will be thankful for your help.
You should use a pivot table, which can easily give you the sum for every date in your table.
Pivot tables are supported in all good desktop spreadsheets, but not many online web-based ones.
See http://en.wikipedia.org/wiki/Pivot_table
I'm still not sure if I got you right.
If you want to add the date as condition, you can try something like that:
Add a formula to your column D: =B1&" "&A1
This should give you the following result:
A B C D
1 10/1/2009 3652449 12:15:43 AM 3652449 40087
2 10/1/2009 3652449 12:17:03 AM 3652449 40087
3 10/4/2009 3652449 1:03:08 AM 3652449 40090
Now you can change your original formula to: =SUMIF(D:D,"3652449 40087",C:C)
You can make column D invisible by either changing width to 0 or changing color to white.
Hope that is what you tried...