3 Replies Latest reply: May 28, 2010 10:31 AM by juergm

# Sort by Expression - User selection for chart

I want to give the user the chance to decide whether he wants to sort by a calculated value or by the Dimension.

Therefor I created a Variable SortBy (Value;Name)

And use the expression:

if( SortBy = 'Value',

min(

if( CompFact > 0,

PRICE / ER_EUR / MP.CONV_F * CompFact,

PRICE / ER_EUR / MP.CONV_F

)

),

PRICE_CHART_LABEL

)

If I use the min() function alone it works. Using the dimension name as expression (here PRICE_CHART_LABEL) doesn't work. Neither the combination as shown above.

Any idea how to implement a user selection for sorting by expression or by dimension ?

• ###### Sort by Expression - User selection for chart

HI

Could it be that the true part of If function contains aggregation (min), but false part does not. Please try MINSTRING() for character dimension and MIN() for numbers.

Cheers Darius

• ###### Sort by Expression - User selection for chart

Hi Darius,

thanks for the quick reply. I tried but it doesn't work. By the way, the min() is only used because the chart has a second dimension. So what I I want to do: give the change to sort either by dimension 1 (Country) or by the min() of the all y-values, prices for different customers (dimension 2) in a country.

I tried with a simplified example with one dimension and a simple expression:

x, y1, y2
a, 2, 4
b, 1, 4
c, 3, 2
];

Chart:

Dimension = x, Expression = y1 * y2

Var: SortBy VarValues: (Name; Value)

Sort by expression:

if( SortBy = 'Value',
(y1 * y2),
x)

Doesn't work either. Each statement alone works...

• ###### Sort by Expression - User selection for chart

Hi Christian

you should be able to set the sort order by macro. Look for the automation examples when searching for *sortby*.

Regards

Juerg