Converting an Index Match Setup to Tadabase
How to convert an Index Match setup to Tadabase:
1. If you’re working with just a few basic values, you can use an equation field with IF statements.
https://www.youtube.com/watch?v=B1LJ4bHRb4g
2. If it’s somewhat more complex, you can use some JavaScript Pipe:
3. If you need a true Index and Match you can turn your Google Spreadsheet into a standalone database and run a request against it in conjunction with a Pipe.
Google App Script Code:
function doGet(e) {
var INCOME=e.parameter.INCOME
var RATE=e.parameter.RATE
var response=findRow(INCOME, RATE)
return ContentService.createTextOutput(JSON.stringify(response) ).setMimeType(ContentService.MimeType.JSON);
}
function findRow(INCOME, RATE){
const ss=SpreadsheetApp.getActiveSpreadsheet()
const sheet=ss.getSheets()[0]
const data=sheet.getDataRange().getValues()
const header=data[0]
var result=[]
data.forEach(function(row){
if(row[0]==INCOME) return result=row
})
var val1;
for(var i=0; i<header.length; i++) {
Logger.log(header[i]+ ' ' + RATE)
if(header[i] == RATE) {
val1=result[i]
return;
}
}
if (val1 == undefined) {
for(var i=1; i<header.length-1; i++) {
if (header[i] < RATE && header[i+1] > RATE) {
if ( Math.abs(header[i]-RATE) > Math.abs(header[i+1]-RATE) ) {
val1 = result[i+1];
} else {
val1 = result[i];
}
}
}
}
return (val1)
}
function toJson(header,values){
var obj={}
header.forEach(function(key,i){
obj[key]=values[i]
})
return obj
}
Original Community Post:
https://community.tadabase.io/t/converting-an-index-match-setup-to-tadabase/2140/2
We'd love to hear your feedback.