Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
atsushi_saijo
Contributor II

Order By trouble: How could we order by 2 columns of numeric columns in Desc?

I just found an issue when handling 2 array of numeric field to order by. (Because QlikView does not support longer numeric, we had to separate timestamp part and mili-second part, and sort using both.)

How could we order by 2 columns of numeric columns in Desc?

In below example, if we Order By Sort_a desc, it produces:

Error 11.jpg

However, if we do Order By Sort_a, Sort_b desc, QlikView sort it firstly by Sort_a, then re-sort by Sort_b in asc.

Error 12.jpg

[Test Data]

Condition: Load * Inline [

Sort_a,Sort_b,V,Row

20150121081635,7230000,A,1

20140213083241,6180000,A,2

];

NoConcatenate

Result: Load *, RowNo() Resident Condition Order By Sort_a, Sort_b desc desc; Drop Table Condition;

[Background]

Often we ought to select only latest value per xxx (something). We order by timestamp, then group by, by having FirstValue(...).

Tags (2)
1 Solution

Accepted Solutions
neetha_p
Honored Contributor

Re: Order By trouble: How could we order by 2 columns of numeric columns in Desc?

Hi,

Try:

Condition:
Load * Inline
[
Sort_a,Sort_b,V,Row
20150121081635,7230000,A,1
20140213083241,6180000,A,2
]
;

NoConcatenate

Result:
Load *,
RowNo()
Resident Condition
Order By Sort_a desc, Sort_b desc;

Drop Table Condition;

Regards

Neetha

View solution in original post

4 Replies
neetha_p
Honored Contributor

Re: Order By trouble: How could we order by 2 columns of numeric columns in Desc?

Hi,

Try:

Condition:
Load * Inline
[
Sort_a,Sort_b,V,Row
20150121081635,7230000,A,1
20140213083241,6180000,A,2
]
;

NoConcatenate

Result:
Load *,
RowNo()
Resident Condition
Order By Sort_a desc, Sort_b desc;

Drop Table Condition;

Regards

Neetha

View solution in original post

Re: Order By trouble: How could we order by 2 columns of numeric columns in Desc?

Order By Sort_a desc, Sort_b desc


instead of


Order By Sort_a, Sort_b desc desc

atsushi_saijo
Contributor II

Re: Order By trouble: How could we order by 2 columns of numeric columns in Desc?

Thanks it works.

atsushi_saijo
Contributor II

Re: Order By trouble: How could we order by 2 columns of numeric columns in Desc?

Thanks, it works.