Hi all. Finding my way around Looker after many years with Tableau and R. Thanks for reading.
This is a very boring question, but the client wants certain values to show in only the first row of the view. What I mean is this: Say we have a very simple table.
create table foobar (idx int, val varchar(5));
insert into foobar (idx, val) values (1, 'hello'), (2, 'hello'), (3, 'world'), (4, 'world');
If the user viewed this table in Looker and sorted ascending by idx, it would look like
1 - hello
2 - (null)
3 - (null)
4 - (null)
But if they sorted it descending it would look like
4 - world
3 - (null)
2 - (null)
1 - (null)
I tried a table calculation something like this:
if(row() = 1, ${explore_name.val}, null)
But I get an error:
Field "explore_name.val" is not in the current query
Is there a way around what I’m running into here? Maybe I’m just going about it wrong?
Hi Benjamin,
Welcome to the Looker Community!
explore_name.val
has to be added to the results table/query… Then select Hide from visualisation
to actually not show it.
The reason for it is because Table Calculations work on the data layer returned from the query, not in the query itself.
So, add the field, hide it, and then Table Calculation show work fine
Thank you so much! I really appreciate your answer. It both showed me what to do and helped me understand why. And it was just in time for me to start up with fresh eyes in the morning!