Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld happening right now! You can still join: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Inconsistent results with SortByNumeric - it toggles ascending/descending

Greetings.

I have the following subroutine, that seemed to be working fine with v8.5, but now seems to be toggling instead of consistantly setting the sort in ascending order.  The subroutine is as follows

SUB TableChartSortNumericAscending  (SheetName, ObjectName, ColumnNumber)

    ActiveDocument.Sheets(SheetName).SheetObjects(ObjectName).Restore

    ActiveDocument.GetApplication.WaitForIdle 3000

    ActiveDocument.Sheets(SheetName).SheetObjects(ObjectName).SortBy ColumnNumber

    ActiveDocument.GetApplication.WaitForIdle 3000

    set TableChart=ActiveDocument.GetSheetObject(ObjectName)

    set Prop = TableChart.GetProperties

    if TableChart.GetObjectType=4 then            'Its a Table

        Prop.Layout.ColLayouts.Item(ColumnNumber).SortCriteria.SortByNumeric = 1

    else

        set vars = Prop.Dimensions

        vars.Item(ColumnNumber).SortCriteria.SortByNumeric = 1

    end if

    ActiveDocument.GetApplication.WaitForIdle 3000

    TableChart.SetProperties Prop

END SUB

It does pretty much as it says:  Sets a column in a table or chart to sort numerically in ascending order.  Well, it used to.  Now when I run it, if the column is currently set to ascending, after running the macro, it will be set to descending.  If it was set to discending before running the macro, it will then be set to ascending.

I want this macro to *always* set the column to ascending, regardless what it's currently set to.

What am I doing wrong?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

I discovered the numbers of the fields changed.  It used to be that the field numbers were by visible fields.  It now appears that the SortByNumeric is by the actual column number, regardless if it displays or not.

All working, now.

View solution in original post

1 Reply
Not applicable
Author

I discovered the numbers of the fields changed.  It used to be that the field numbers were by visible fields.  It now appears that the SortByNumeric is by the actual column number, regardless if it displays or not.

All working, now.