Dimension and measures

I am new to looker and can someone tell me the which is the right SQL while creating a measure or dimension. I have a table named Sales and dimension named Customer

1)${TABLE}.Customer

2)${Customer}

3) $Sales.Customer

When to use which of the above format and what is the difference

Solved Solved
0 1 435
1 ACCEPTED SOLUTION

antho
Participant IV

Hello,

I recommend you read this article about SQL and LookML references and susbtitution operator 😉 

https://docs.looker.com/data-modeling/learning-lookml/sql-and-referring-to-lookml

Basically, using TABLE something means you reference a field of your database column directly. Then $fieldname means you reference a field already defined in a LookML view.

Imagine you use this field in 10 different occurences: for example, you have multiple series of transformation on this field, maybe a CASE WHEN statement for grouping, some capitalization cleanup etc… If you were using everytime TABLE.customer, it means that if one day this column changes in the db (for ex, it becomes customerS), you have to replace it in every dimension you used this field. Instead, if you used $customers, you would just need to replace your base dimension TABLE.customerS and then the changes would propagate 🙂

It’s a stupid example but hopefuly, it clarifies 😉

Antho

View solution in original post

1 REPLY 1

antho
Participant IV

Hello,

I recommend you read this article about SQL and LookML references and susbtitution operator 😉 

https://docs.looker.com/data-modeling/learning-lookml/sql-and-referring-to-lookml

Basically, using TABLE something means you reference a field of your database column directly. Then $fieldname means you reference a field already defined in a LookML view.

Imagine you use this field in 10 different occurences: for example, you have multiple series of transformation on this field, maybe a CASE WHEN statement for grouping, some capitalization cleanup etc… If you were using everytime TABLE.customer, it means that if one day this column changes in the db (for ex, it becomes customerS), you have to replace it in every dimension you used this field. Instead, if you used $customers, you would just need to replace your base dimension TABLE.customerS and then the changes would propagate 🙂

It’s a stupid example but hopefuly, it clarifies 😉

Antho

Top Labels in this Space
Top Solution Authors