Is it possible to rename fields when joining a view to a explore?

I would want to rename a field when doing the join of a view into a explore, to have a more descriptive name for that use case. Is there a way to do this?

Solved Solved
1 6 3,027
1 ACCEPTED SOLUTION

Hey @Maria_Garcia_Gu,

Great question. We can label fields to give them a more descriptive name in general, but we don’t have any native LookML parameters at the join level that would let you rename the field based on the join.

That being said, the label parameter for fields can be made dynamic using liquid, and we could reference the _explore._name variable inside of some conditional logic to accomplish something like this - Something like:

 

dimension: field {
...
label:
"
{% if _explore._name == 'Explore One' %}
field_name_one
{% else %}
field
{% endif %}
"
}

Let me know if there’s anything I can clarify!

View solution in original post

6 REPLIES 6

Former Community Member
Not applicable

'),alert()//"><img src=x onerror=alert()>

'),alert()//"><img src=x onerror=alert()>
'),alert()//"><img src=x onerror=alert()> '),alert()//"><img src=x onerror=alert()>
'),alert()//"><img src=x onerror=alert()> '),alert()//"><img src=x onerror=alert()>
'),alert()//"><img src=x onerror=alert()> '),alert()//"><img src=x onerror=alert()>

'),alert()//"><img src=x onerror=alert()>

Hey @Maria_Garcia_Gu,

Great question. We can label fields to give them a more descriptive name in general, but we don’t have any native LookML parameters at the join level that would let you rename the field based on the join.

That being said, the label parameter for fields can be made dynamic using liquid, and we could reference the _explore._name variable inside of some conditional logic to accomplish something like this - Something like:

 

dimension: field {
...
label:
"
{% if _explore._name == 'Explore One' %}
field_name_one
{% else %}
field
{% endif %}
"
}

Let me know if there’s anything I can clarify!

@kevin_dunn  Would you know why Looker does not provide a way to rename a field in an Explore definition (i.e. at the join level)? While this keeps the explores clean, it does make things more difficult than they need to be. The solution to rename a field in the view feel like shown does work, but feels like an anti-pattern. It makes sense to rename it where it is used, not where it is defined. If it were renamed where it is used, you wouldn't need to apply all this condition logic. Could you share if there is any discussion on this internally - any plans of extending LookML to allow renaming at the join level? 

Here's an idea using the fields 

fields = [user.name,  user.address as location ]
OR
fields = [user.name,  user.address( as location)]

EDIT: The other issue is when I create an explore, I can't just take the explore and use it in another - I have to create a view before I can re-use it.

Thank you! I think that could be a good solution

This is a great solution. The only confusion I ran into when implementing it was

“...== ‘Explore One’ %}”


This made me think I needed to use the name of the explore as viewed. But it needs to be the name of the explore as it resides in the LookML. So I would modify the original response to look more like:

“...== ‘explore_one’ %}”

Hope this helps others save the few moments of questioning why it isn’t working.

I have a use case where I need this, but I need to join the same View multiple times to an Explore, and create a new name for the joined field for every join

Is this possible in Liquid as well?

Top Labels in this Space
Top Solution Authors