I have a range
idz01 idz04 ida02
foo a 1 b
bar c 3 8
baz 8 2 g
And I want to get values from this range, like this:
SOME_FUNCTION(rangeID, 'foo', 'idz04')
to get 1
, etc. Or ideally, to get the cell:
INDIRECT(SOME_FUNCTION(rangeID, 'foo', 'idz04'))
or such.
Is there something such? Can the GETPIVOTDATA()
be used for that?
Edit:
I could somehow employ the LOOKUP
if I was able to get the result_range
:
LOOKUP("foo", DataRange,
FIRST_COL(
OFFSET(DataRange,
MATCH("idz04", FIRST_ROW(DataRange), 0)
)
)
)
Only, I don't have FIRST_ROW()
and FIRST_COL()
... Maybe FILTER()
could help?
Try this, you just need to set ranges:
=INDEX("Talbe",MATCH("foo","First Column",0),MATCH("idz04","First Row",0))
For example if your table is in the range A1:D4, use:
=INDEX(A1:D4,MATCH("foo",A:A,0),MATCH("idz04",1:1,0))
You can also use named ranges
To get first columns and rows automatically use this formula:
=INDEX(data,MATCH("foo",INDIRECT(CHAR(64+COLUMN(data))&":"&CHAR(64+COLUMN(data))),0),MATCH("idz04",INDIRECT(COLUMN(data)&":"&COLUMN(data)),0))
To do this via script, use this code:
function LOOKUPGRID(data, rowHeader, colHeader) {
for (var i = 0; i<data.length;i++) {
if (data[i][0] === rowHeader) {
for (var j = 0; j<data[0].length;j++) {
if (data[0][j] === colHeader) {
return (data[i][j]);
}
}
}
}
return (null)
}
You can then call the formula in your sheet like this:
=LOOKUPGRID(A1:D4,"foo","idz04")
For this you could write a custom function using Google Apps Script. Check this documentation for more details.
You could access the spread sheet with name or id and get the range of values(in your case a cell).
Hope that helps!
Here it goes:
=INDEX(ObjednavkyData,
// Find the offset of "vesela01" in the 1st column
MATCH("vesela01",
OFFSET((ObjednavkyData),0,0,
MAX(ARRAYFORMULA(ROW(ObjednavkyData))) // Num of rows in the range
, 1)
,0),
// Find the offset of "z03" in the 1st row
MATCH("z03",
OFFSET(ObjednavkyData, 0 , 0, 1) // First row
, 0))
Not really neat :P
Also see Google Spreadsheets: How to get a first (Nth) row/column from a range? (built-in functions)
Tried to write my own function...
/**
* Returns [Range] the cell value at coordinates determined by the values first row (colHeader) and first column (rowHeader) in given range.
*/
function LOOKUP_GRID(range, colHeader, rowHeader){
for(var col = range.getWidth()-1; col--; col >= 0 )
if(range.getCell(1, col).getValue() === colHeader)
break;
for(var row = range.getHeight()-1; row--; row >= 0 )
if(range.getCell(row, 1).getValue() === rowHeader)
break;
if(col === -1 || row === -1)
return null;
else
return range.getCell(row, column)
}