Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Help with sort order

Hi all,

I am having trouble getting a sort order correct to a clients needs.

I have the following sort orders in the script.

LOAD * INLINE[
Bill_Class_Model,Sort_Order1
U,1
A,2
M,3
]
;
LOAD * INLINE[
Account_Det_ID_Model,Sort_Order2
DU,1
CU,2
CM,3

DM,4
]
;

What they want is if Bill_Class_Model = M then Sort_Order2 needs to be sorted in descending order otherwise sort in ascending order.

Can anyone help please?

11 Replies
Not applicable

I try to put an expression like this in the tab order:

= If (Bill_Class_Model = 'M', (-1) * Sort_Order2, Sort_Order2)

Check ascending order.

A greeting.

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Daniel,

That didn't work. The field i am sorting is all in ascending order

I am struggling with this problem..

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

I don't know if it makesd a difference but i am trying to sort the data in a pivot table

Not applicable

I am attaching a document with an example.

I hope that helps you serve, if I understand you.

If you select the value of M, see you descending order.

A greeting.

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi again,

I have attached your sample, I have added the field Bill_Class_Model to the pivot table, as you can see it all shows ascending order.

It worked if the Bill_Class_Field was not part of the pivot table, but as you can see it doesn't wotk with that field added in..

It works if i select Bill_Class_Model U, i want it to work without any selections though.

This is how i want it to look:

Bill_Class_Model    Account_Det_ ID_Model       

U                                DU

                                  CU

                                  CM

                                  DM 

A                                DU

                                  CU

                                  CM

                                  DM

M                               DM

                                  CM

                                  CU

                                  DU

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Use dual values, with the sort order the numeric value. You can then sort the values using numeric sorting. Modify your loads as follows:

LOAD Dual(Bill_Class_Model, Sort_Order1) As Bill_Class_Model  //, SortOrder1  // remove comment if you still need SortOrder1/2

[

     Bill_Class_Model, Sort_Order1

....

]

Make sure you change the sort to numeric.

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Jonathan, sorry, what do i need to change my scipt to please?

jonathandienst
Partner - Champion III
Partner - Champion III

Replace the first LOAD* INLINE with

     LOAD Dual(Bill_Class_Model, Sort_Order1) As Bill_Class_Model


Replace the second LOAD * INLINE with

     LOAD Dual(Account_Det_ID_Model, Sort_Order2) As Account_Det_ID_Model

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Jonathan,

I have replaced what you have said but i am getting syntax errors. Have i done something wrong?