Hi everyone,
I am trying to figure out how to be able to select from a list of Entity Names, then have the Entity Key related to the selected name be used for variables in my SQL queries on that dashboard. Is this something that can be done? I've been fighting this for too long!
Hello joshc,
If I undestand well, in your data you have something like this :
id | name
-----------
1 | sample1
2 | sample2
...
And you want to have a selection list for you filter with :
[] sample1
[] sample2
...
But in your querie , you want something like :
select * from tab where {{id}};
Is that right ? If not, can you send a screen of how you have configure the filter (variable) and the query you wanted to do ?
yes, that's precisely what I'm looking to do!
For me it's impossible to do it "with" metabase like you expect. But you have others possibilities using SQL.
First I don't really undestand why you couldn't/wouldn't used directly the name
select * from tab where {{name}};
Else maybe you can use a CASE condition, if you need a result depending of name's value
SELECT CASE {{name}}
WHEN 'sample1' THEN id
WHEN 'sample2' THEN 'unwanted'
END value
FROM tab
Maybe you can also solve you problem by changing the filtes widget's shape
Without precision about the final objective (why do you want to have a relation table between two fields of your table ?), I can't help you more.
@zolora That logic checks out - I'll try to make it work with that. The reason for the aversion to using the name is the name value is not a Unique ID, where as the Entity Key is.
So I can be sure I'm headed in the right direction, are you recommending I create a model with a query structured like the one you've provided and then apply that model to the text dropdown on the Dashboard?
also thank you immensely for the assistance so far.