Forum Discussion
OFFSET nested in COVARIANCE.S returns a #NUM! error
- May 22, 2022
Assuming I understood...
in MATRIX!B2:
=COVARIANCE.S( OFFSET(DATA!$B$2, 0, INDEX(COLUMN(B$1)-2,1), COUNTA(DATA!$A:$A)), OFFSET(DATA!$B$2, 0, INDEX(ROW($A2)-2,1), COUNTA(DATA!$A:$A)) )
If this does what you want and run Excel 2021 or 365 see (in attached file) another option using XLOOKUP instead of OFFSET
Thanks so much for your help. You are right the formula I posted can be simplified however I need this to be dynamic as I want a matrix as a final result.
Any idea how to solve it? 🤔
however I need this to be dynamic as I want a matrix as a final result
I'm afraid I don't understand. Could you try again and maybe post picture(s) to illustrate what you have & expect?
- Arnaud1010May 22, 2022Copper Contributor
I reproduced the spreadsheet but can't post it somehow. Please find below the screenshots. Raw data is in DATA tab and the covariance Matrix is in MATRIX tab.
MATRIX tab
The final result is a Matrix of n*n size that needs to refer to the proper columns in DATA tab.
DATA tab
This is the data tab.
And the formula (in B2) looks like that, but as you can see produce the #NUM! error...
Formula in the matrix cell
Thanks for your help!
Arnaud
- LorenzoMay 22, 2022Silver Contributor
Assuming I understood...
in MATRIX!B2:
=COVARIANCE.S( OFFSET(DATA!$B$2, 0, INDEX(COLUMN(B$1)-2,1), COUNTA(DATA!$A:$A)), OFFSET(DATA!$B$2, 0, INDEX(ROW($A2)-2,1), COUNTA(DATA!$A:$A)) )
If this does what you want and run Excel 2021 or 365 see (in attached file) another option using XLOOKUP instead of OFFSET
- Arnaud1010May 23, 2022Copper Contributor