You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/08 06:40:29 UTC

[GitHub] [incubator-superset] kwims commented on issue #9999: Filter before grouping

kwims commented on issue #9999:
URL: https://github.com/apache/incubator-superset/issues/9999#issuecomment-640400732


   Hi @rumbin , I was able to fix the code by using jinja template and Calculated Columns. I have been inspired by this ticket https://github.com/apache/incubator-superset/issues/4181.
   
   _Note I updated the example to add another column._
    
   SQL was like : 
   `Select count(*), time  USER_PRESENTATION_TAG_VIEW where tag = 'java' group by time`
   
   What I manage to do with jinja was to do update Datasource of USER_REPRESENTATION as follows:
   ```
   Select * USER_PRESENTATION where id in (select id from USER_PRESENTATION_TAG_VIEW where 
    {% set f_tag = filter_values('tag') %}
       {% if f_tag %}
   		AND tag in ( {{ "'" + "','".join(f_tag) + "'" }} )
      {% endif %}
   )  group by time
   ```
    
   Finally my SQL looks like:
   `Select count(*), time USER_PRESENTATION where id in (select id from USER_PRESENTATION_TAG_VIEW where tag = 'java')  group by time`


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org