Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

class/Rank/group

Hi,

i need the sorting order for the particular range

please find the attachements

!

14 Replies
Anonymous
Not applicable
Author

select RangeOfsales from table group by RangeOfsales order by

case

when RangeOfSales = Less than 1K' then 1

when RangeOfSales = '1k-2k' then 2

when RangeOfSales = '3k-5k' then 3

end asc;

how to use the abvoe query in QV. (in DB executing this query givig me the proper sort order, i need to take it to QV)

consider there are one or more columns like RangeOfsales to sort . ex: RangeofPrices ....

requierd help

timanshu
Creator III
Creator III

load  only(RangeOfsales ),pick(match(RangeOfsales ,'Less than 1K','1k-2k','3k-5k'),1,2,3) as grouping from (path of file) group by RangeOfsales;

including more fields on group by like RangeofPrices  will not give right results.

ex:

rangeofsales,  rangeofprices

1k-2k,  3k-5k

1k-2k,4k-8k

then output will only show

rangeofsales,  rangeofprices,grouping

1k-2k, 3k-5k , 1

Anonymous
Not applicable
Author

so is there any alternative way to get the sort?

timanshu
Creator III
Creator III

Simply do like this

Load if(sales>1000 and sales<2000, '1k-2k',

              if(sales>2000 and sales<5000, '2k-5k', 

                 if(sales>5000 and sales<10000, '5k-10k',

))) as range.

ramoncova06
Partner - Specialist III
Partner - Specialist III

you could use dual like Robert already suggested

how do you create your ranges ?

I am assuming with a nested if so you could do something like this

if (Sales < 1000,  dual('less than  1k ',1),

         if(Sales <= 2000, dual('1k-2k ',2),

               if(Sales <= 5000, dual('3k-5k ',3),

   .......

and then you apply a sort based on the numeric value of the field