2 Replies Latest reply on Jul 18, 2018 9:52 PM by Ashok Ramineni

    Convert Query to Tableau

    Ashok Ramineni



      Can you please advice in converting the below query to Tableau. Month is my Dim & Sales/Qty is my measure.



      select month, avg(Sales/Qty) from TABLENAME

      where Region='Central'

      location = 'All'

      and Type = 'All'

      and CName <> case when :input = 'All' then 'All' else '*#$#' end

        and  CName =  case when :input = 'All' then CName else :input end

        group by month


      :input --> user selection filter.


      Tableau: I am not getting proper results with my query..am I doing anything wrong..


      IF ATTR([Cname]) <> case ATTR([SEC].[CNAME]) WHEN "All" then "All" else "*#$#" end

      AND ATTR([Cname]) = case ATTR([SEC].[CNAME]) WHEN "All" then ATTR([Cname])  ELSE ATTR([SEC].[CNAME])   end

      THEN AVG({ FIXED [Region] [LOCATION],[Type], [Month]: AVG([Sales]/[Qty])})



      ATTR([SEC].[CNAME]) --> user selection filter; from a different data source derived from main data source.