Using sql subquery in Tableau -
i trying calculate new field in tableau similar sub query in sql. however, numbers not matching when try this. stuck @ point , trying see others have done.
to provide reference, below subquery trying duplicate in tableau.
select ((sum(n.non_influenced_sales*n.calls)/sum(n.calls))-(sum(n.average_sales*calls)/sum(calls))))/ (sum(n.non_influenced_sales*n.calls)/sum(n.calls)) impact (select count(d.id) calls ,avg(d.sale) average_sales ,avg(case when non_influenced=1 d.sale else null end) non_influenced_sales data d group skill) n when try build same calculation in tableau, able same results long comment out group skill. however, when try group skill, attempts match number have not been working.
the closest have come when try fix level of detail expression using include. tableau code:
(include [skill]:([non_influenced_sales]-[average_sales])/[non_influenced_sales]} however, doing or using fixed has not worked , can't match numbers getting sql.
fyi, impact aggregated measure. built sub-query part in tableau creating separate fields calculation needed. example non influenced sales calculated in tableau:
avg(if [non_influenced]=1 [non_influenced_sales] end) however, not sure if matters or not.
i have tried creating custom sql. able rolled version using of dates correct. when want down different dates/use other filters, things messy real quick. trying build relationships on date level, hasn't worked either.
is there easier way this?
Comments
Post a Comment