# Vlookup

## Inspired by Excel... a VLookup experience that works in SQL

### Required Inputs

* Lookup Column: The column to look up in the Lookup Table. Make sure the column is named the same in both tables.
* Lookup Table: The table to look up the Lookup Column in.

### Optional Inputs

* Keep Columns: The columns to keep from the Lookup Table. If not provided, all columns from the Lookup Table will be kept.

### Notes

* For values that don't find a match in the lookup\_column, you will see Null
* For columns that have the same name in both tables, the columns in the Lookup Table will be prefixed with the table name

## Parameters

| Name           | Type         | Description                            | Is Optional |
| -------------- | ------------ | -------------------------------------- | ----------- |
| lookup\_column | column       | Column to look up in the lookup table  |             |
| lookup\_table  | table        | Table to look up the lookup\_column in |             |
| keep\_columns  | column\_list | Columns to keep from the lookup table  | True        |

## Example

```python
internet_sales = rasgo.get.dataset(74)
customer = rasgo.get.dataset(55)
product = rasgo.get.dataset(75)

ds2 = internet_sales.vlookup(
  lookup_column='PRODUCTKEY',
  lookup_table=product.fqtn,
  keep_columns=['WEIGHT', 'ENGLISHDESCRIPTION']
)
ds2.preview()
```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/vlookup/vlookup.sql>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/vlookup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
