R SQUARED Formula Based on Conditions - excel-formula

I am trying to insert the R squared formula as follows:
=RSQ(Known_ys, Known_xs) ONLY if row(i)= "YES" and ignore the rest of the data. For instance, the below should calculate RSQ excluding the rows where values in column C ="NO". I tried the following formula, but it didnt work: = {IF(C1:C4="YES",RSQ(B1:B4,A1:A4),"")}
A
B
C
6.2
3.79
YES
7.2
4.56
NO
8.8
6.22
YES
4.5
8.9
YES

♣SOLVED♣
Here you go (in relation to screenshot below):
=RSQ(IF($C$1:$C$4="YES",B1:B4,""),IF(C1:C4="YES",A1:A4,""))
Ta,
J

Related

Repeat values n times where n could also be 0.5

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

Associate values in excel between different column

I have two different series of data that look something like this
A B
1 0.998
2 0.9975
3 0.997
4 0.9967
5 0.9962
6 0.9960
.
.
.
and
C D
1 240.5
1.3 249.5
1.7 241.45
2 239.0
2.5 124.5
3 125.6
3.4 235.1
3.5 236.4
.
.
.
How can I merge the two in excel so that the end results will look like this?
C C E
1 240.5 0.998
1.3 249.5 0.998
1.7 241.45 0.998
2 239.0 0.9975
2.5 124.5 0.9975
3 125.6 0.997
3.4 235.1 0.997
3.5 236.4 0.997
Essentially I need to add, for each integer of the column C, its corresponding value as shown in the series A,B. the whole dataset is 3500 rows long, so I am looking for an automated solution that can help me with that before I resolve to painstakingly paste each value in its position.
In column E you can create a formula that uses your first table (A/B) as a LOOKUP table. Truncate the value in Column C as your lookup value.
So in column E, use a formula something like,
=LOOKUP(TRUNC(Cx), A1:An, B1:Bn)
where x is the row number of your C/D/E table, and n is the last row in your A/B table.

Find and replace values within ranges in excel

I have an array in excel that looks something like this, though much larger:
A B C D E F G
0 0 0 0 2.78 2.48 2.11
0 0 0 3.11 2.94 2.78 2.15
0 0 0 2.72 2.7 2.2 2.15
0 1.68 2.44 2.29 2.13 0 0
1.89 1.97 2.43 2.07 0 0 0
I'm trying to find all the values within an interval, then replace them with a different value according to a chart that looks like the one below. The values in the first row are the limits of an interval, and the second row represents the value I would like to insert into the array above. For example, the value in cell A5= 1.89. 1.89 falls between 1.8 and 1.9 so according to the chart below I would like the output to be 19.9192.
A B C D E F G ........>
1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3 3.1 3.2
19.51 19.721 19.9192 20.1088 20.2903 20.4644 20.6318 20.7928 20.9484 21.0986 21.2441 21.3849 21.5214 21.654 21.7829 21.9083 22.0304
In terms of finding the values, I've tried the following :
=AND(A1 > Lower limit ,A1< Upper limit)
And using the Lower/ Upper limits as neighboring cells in the chart. For example,
=AND (A1> A10, A<A11)
which returns a value of either FALSE or TRUE depending of if the cell A1 is within the specified interval. I realize this isn't quite right but I'm not sure how to proceed. If its TRUE, I'm not sure how I can then insert the value I want based on the second chart - for example 19.9192 if the value was between 1.8 and 1.9, and if FALSE, I'm not sure how I can than move on to check the next interval and keep checking intervals until the right one is found an the cell is replaced appropriately. I think a loop might be needed, but I've not worked much with excel and haven't been able to get any syntax right to try it out.
A second look at your reference data, the format is in precision of 0.1. Whereas the input data is of 0.01 and 0.1. another condition is you take the lower bound of the difference. Thus, I would roundup the value 1st, then query the ref table using it. eg. 1.89 > convert to 1.8 > look for 1.8 pair value > retrieve value.
in I2 enter :
=IFERROR(INDEX($11:$11,MATCH(INT(A1*10)/10,$10:$10,0)),"") and drag it until O6.
+----[formula breakdown:]----+
round the number to 0.1 precision > INT(A1*10)/10
look for 1.8 position in the selection > match()
retrieve the value from the position identified > index()
hope that helps. (:

Excel count columns where values match and value is above threshold

Im trying to find matches between column B and C when the value in A is above a certain threshold.
0.99 p269 p269
0.99 p312 p312
0.64 p249 p249
0.64 p247 p247
0.09 p243 p284
I'm trying the Countifs method but it doesnt work.
=COUNTIFS(
A1:A31968,">" & F2,
B1:B31968,C1:C31968
)
The first part works (F2 is my treshold), but the I want to check all rows.
So when my threshold is 0.5 I want 4 as a result. When the threshold is 0.08 I still want 4 because the labels of the fifth row don't match. How do I do this?
One option would be to add a fourth column to spreadsheet in column D containing the following formula:
=IF(B1=C1, 1, 0)
Here is what your spreadsheet looks like now:
A B C D
0.99 p269 p269 1
0.99 p312 p312 1
0.64 p249 p249 1
0.64 p247 p247 1
0.09 p243 p284 0
In other words, if columns B and C agree, there is a 1 otherwise 0. Then, you can use the following COUNTIFS formula:
=COUNTIFS(A1:A5,">0.5",D1:D5,"=1")
Here we check the 0.5 threshhold on column A as you were already doing, but we also check that the B and C values are in agreement.
The other option is to use a pseudo-array formula
=SUMPRODUCT((A1:A5>F2)*(B1:B5=C1:C5))
to combine the two conditions. It doesn't have to be entered as an array formula, but may have performance issues if used on several thousand rows of data.

Excel - Include Row in Sum Based on Comparison to Following Row

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))

Resources