ptheru commented on issue #13943:
URL: https://github.com/apache/superset/issues/13943#issuecomment-816857489
Hi there!
I have similar scenario like yours @cccs-jc
my query -
P.S - time_filter() in the below query is a custom function in
jinja_context.py
```
{% set dttm = time_filter() %}
WITH User_purchased_within_30_days as (
...)
SELECT UserID,
month,
count_if(Matched = 1)/count(distinct PRODUCT_LANDED) as
conversion_per_user
FROM User_purchased_within_30_days
WHERE Purchase_date {{ dttm }} #jinja
GROUP BY UserID,
month
HAVING count_if(Matched = 1) > 0
ORDER BY UserID,
month
```
The jinja is applied correctly in the query generated by superset inside the
explore view -
```
SELECT "MONTH" AS "MONTH"
, CASE
WHEN COUNT(DISTINCT USERID) = 0 THEN 0
ELSE SUM(CONVERSION_PER_USER)/COUNT(DISTINCT USERID)
END AS "Rate"
FROM
(WITH User_purchased_within_30_days as (
...)
select UserID,
month,
count_if(Matched = 1)/count(distinct PRODUCT_LANDED) as
conversion_per_user
from User_purchased_within_30_days
where Purchase_date >= '2021-04-02'
AND Purchase_date < '2021-04-09'
group by UserID,
month
having count_if(Matched = 1) > 0
order by userid,
month) AS virtual_table
```
In the dashboard view, the filter values do not pass through the chart. I
get an incompatible filter warning.

I tried adding a calculated column as I do not want my query to be split by
date. I just want it to be filtered by date.

Generated SQL query -
```
SELECT "MONTH" AS "MONTH"
, CASE
WHEN COUNT(DISTINCT USERID) = 0 THEN 0
ELSE SUM(CONVERSION_PER_USER)/COUNT(DISTINCT USERID)
END AS "Rate"
FROM
(WITH User_purchased_within_30_days as (
...)
select UserID,
month,
count_if(Matched = 1)/count(distinct PRODUCT_LANDED) as
conversion_per_user
from User_purchased_within_30_days
where Purchase_date >= '2021-04-02' #jinja
AND Purchase_date < '2021-04-09' #jinja
group by UserID,
month
having count_if(Matched = 1) > 0
order by userid,
month) AS virtual_table
WHERE Purchase_date >= '2021-04-02 00:00:00.000000' #do not want this line
as jinja is already applied above
AND Purchase_date < '2021-04-09 00:00:00.000000' #do not want this line as
jinja is already applied above
```
Is there a work around for me to get superset to hide those two last lines?
Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]