Hi Folks,
I want to create custom decile for my project. Tile tool is not helping much in obtaining required results. I want to convert below sql code into Alteryx environment to get the appropriate deciles. Can anyone help me in this.
Thanks in advance!
(data attached for reference)
-- Code for Creating deciles
create or replace table identifier($tablef) as
with temp as (
select npi, count(distinct patient_id) as pats, count(distinct claim_id) as trx
from identifier($table2)
where npi is not null
group by 1
)
,
running as (
select *
, SUM(trx) OVER (ORDER BY trx DESC) as running_trx
, SUM(trx) OVER (ORDER BY trx DESC) / SUM(trx) OVER () as ratio
, 11 - ceil(10 * SUM(trx) OVER (ORDER BY trx DESC) / SUM(trx) OVER ()) as decile
from temp
)