1 2 Previous Next 16 Replies Latest reply on Aug 3, 2018 5:38 AM by karthik Valluri

    How to group records in buckets and get highest value

    karthik Valluri

      Hi Everyone,

       

      I have a requirement to group records into a bucket( take count of records and divide it by 5(as an eg), you would then end up with 20

      buckets with 5 records in each. Then assign get highest record from each bucket. I have attached my excel sample with this example. ( here each bucket holds 6 records(30/6)

      Any ideas on how i  should approach doing this in tableau? The output as per below screenshot should be 5 rows.

       

       

      Same can be achieved in T-sql using NTILE function as follows:-

       

      select max(values),count(*) counts ,percentile from

      (

             SELECT ntile(20) over (order by values )*5 percentile,(values ) values

                      FROM [xy].[dbo].[xxx]

                      where values is not null

      )x

      group by percentile

      order by percentile

        1 2 Previous Next