Dimension referencing other view won't work

low_priority
done
reply
(Paul Wadsworth) #1

I’ve got two views for this, an account list, and a list of arrangements.
The model these are in have a FROM: of the account list, with the arrangements view joined.

The account list view is vw_account_list, from the view vwAccountList in our SQL, and has a label of “Account List”.

Because I need to count some of these arrangements with different filters, I went to set up a Dimension, that includes a CASE WHEN, part of which is:

${account list.statusname} =

I tried various vw_account_list instead, but it looks like the correct syntax is “account list” since that’s the only one the validator allowed me to use.

When I try and run an explore using this field I get an error that the from the SQL end, and looking at the SQL it still says

${account list.statusname} =

And it’s the only field in the entire SQL code that includes the $ { } part.
Looking at the SQL, it looks like I need to change “account list” to the name of the Model, since the FROM part is looking at the account list view, giving it the name of the model.

If I change the LookML in the arrangement table to use the name of the model though, it tells me it’s an unknown or inaccessible field.

I know I’m doing something wrong, or just missing something, could someone please point me in the right direction on how I reference the main view of a model in another view?

0 Likes

(Jackson Alvarez) #2

I dont like to use the from: parameter on the base view of an explore. It’s always better idea to use view_name: and then reference the fields normally with the actual view name.

In my experience, this resolves most of these confusing aliased naming problems.
Does that fix it?

0 Likes

(Paul Wadsworth) #3

I might need some guidance on how to do that.

I went into the model, and typed in view_name and the quick helped suggested it works the same as from, so I just switched from to view_name. The model still seems to work in all other regards, but I’m still getting the same SQL error when I try and use the new field.

Now the SQL is saying the account list view is named “vw_account_list” instead of the model name, so it feels like some progress.

So now:

  1. SQL is naming the main table as “vw_account_list” which is the name of the view in Looker.
  2. In the LookML of my arrangement view, it won’t let me use “vw_account_list” it will only let me use “account list” without the validator throwing up an error. This is the “label” of the vw_account_list view.
  3. The SQL is still looking for ${account list.statusname} and throwing up an error.

I know it’s probably me doing something wrong, but it feels like the LookML Validator is saying it has to be named one way, but when Looker is running the SQL it needs to be named the other way.

0 Likes

(Izzy) #4

This stuff is hard to conceptualize without seeing examples— Could you maybe post a truncated snippet of your explore to see exactly how things are being referenced?

This docs section talks about their behaviors: https://docs.looker.com/reference/explore-params/view_name#view_name,_from,_and_label_are_often_confused_but_have_different_behaviors

This is the relevant section that I find extremely helpful usually:

explore: customer {
  view_name: user
}
# Would appear in the Explore menu as "Customer"
# Fields would appear like "User Name"
# You would reference fields like ${user.name}

explore: buyer {
  view_name: user
}
# Would appear in the Explore menu as "Buyer"
# Fields would appear like "User Name"
# You would reference fields like ${user.name}

I realize I haven’t explicitly answered any of your questions, but I think after seeing the example explore I might be able to help more clearly.

0 Likes