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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
andy
Partner - Creator III
Partner - Creator III

Problem with dynamic sort-expression in chart

Hi folks,

I have a chart in which I would like the way to sort being selected by the users.

The chart displays this data

Table1:

LOAD * INLINE [

    dim1, value

    A1, 10

    A1, 1

    A1, 11

    B1, 2

    B1, 36

    C1,3

];

I created a small inline table holding the name of the sorting-approach and the actual expression.

Like this:

SortTable:

LOAD * INLINE [

    sortName,sortExpr2

    Value, sum(value)

    Count,count(DISTINCT value)

    Default,''

];

Then I present the sortName-dimension in a listbox and would like to set the corresponding sortExpr2 as the sorting expression.

I tried this as the sort-expression in the chart:

Only({<sortName = {$(=GetfieldSelections(SortName))}>} sortExpr2)

but currently it doesn't even work in a text-box.

(I also tried with a cyclic dimension and the function-call replaced by getCurrentField(CyclicDim) and by then the expression above worked in a text-box but not as the sort-expression in the chart)

I've been fidling with this for hours and would like som help on the topic. What I'm I doing wrong?

I attach a very small example-application.

brgds

Andy

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable

=$(=only(sortExpr2)) seems to work, though I'm not sure how you could do the default selection.

See attached.

Jonathan

View solution in original post

2 Replies
Anonymous
Not applicable

=$(=only(sortExpr2)) seems to work, though I'm not sure how you could do the default selection.

See attached.

Jonathan

andy
Partner - Creator III
Partner - Creator III
Author

Great!

Thanks.

I solved the default like this (just setting the expression to an empty string)

=if(only(sortName)<>'Default',$(=only(sortExpr2)),'')

/Andy