I have a dashboard that has a single Naive SQL as it's source. The database for that native SQL is a postgress database.
But when I want to add a category filter all I get are invalid fields.
Why is that?
There are no variables added to the SQL, but I did try that once, but all I got was still "no valid fields".
What am I doing wrong?
@DannyK Which version of Metabase? And which database are you querying?
Could you try to simplify your query, just as a test, and post that, so I can try to reproduce?
Hi flamer,
As stated it's version 0.33.5.1 with a postgress database.
I simplified the query a lot by removing a lot of the different WHEN options or columns, but the variables are the thing that matter most.
SELECT
date,
SUM(impressions) AS impressions,
location,
network
FROM(
SELECT
date_trunc('month', date) as date,
SUM(impressions) AS impressions,
CASE
WHEN ( lower(campaign_name) LIKE '%paris%' OR lower(tactic_name) LIKE '%paris%' OR lower(creative_name) LIKE '%paris%') THEN 'Paris'
ELSE 'Other'
END as location,
network
FROM (
SELECT
cast('Platform1' as text) as network,
date,
campaign,
adgroup,
creative,
impressions
FROM
table1
) AS data
GROUP BY
date_trunc('month', date),
location,
network
ORDER BY
date ASC
)org_views
WHERE
date_trunc('month', date) < date(date_trunc('month', now()) )
[[ AND network = {{ platform }}]]
[[ AND location = {{ city }}]]
GROUP BY
date,
location,
network
ORDER BY
date DESC,
location,
network
@DannyK
I’ve tried multiple things, but I cannot reproduce. I’m not sure what’s going on.
Not that I think it will make a difference, but try avoiding the extra spaces: [[ AND network = {{ platform }}]] => [[AND network = {{platform}}]]
When you go to the dashboard, then open your browser developer Network-tab, and when you add the question to the dashboard, you should see a request like /api/card/XX/query - then copy and paste the response data (you can omit the "data":{...} section)
By the way, do you see any warnings/errors in the browser console, when you’re editing the dashboard and trying to add the question or connect filters?
The nested query is a big source for multiple questions.
I can’t split that up in individual sql’s per question unfortunately.
Thank you for your help and Github links.