# 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.

Source: https://tadabase.com/docs/snippets/converting-an-index-match-setup-to-tadabase  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

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](https://www.youtube.com/watch?v=B1LJ4bHRb4g)

2. If it’s somewhat more complex, you can use some JavaScript Pipe:

![Screenshot for “Converting an Index Match Setup to Tadabase”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-07/scaled-1680-/6LNCapture.JPG)

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.

[https://youtu.be/uHh04ixi0S0](https://www.youtube.com/watch?v=uHh04ixi0S0)

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](https://community.tadabase.io/t/converting-an-index-match-setup-to-tadabase/2140/2)
