Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
neetu_singh
Partner - Creator III
Partner - Creator III

Alphabetical Sorting on Click Event


Dear All,

I have two button one is for "ASC" & another is for "DESC". What I need is when I click on ASC button then in my bar chart data should be sorted into Alphabetical Order from A>B>.............Z & when I click "DESC" then it should be Z>>>>>Y.........................A

Need the same in a single chart. Right now am achieving the same by using "wild match" function with in Sort Expression.

Is there any other best way to achieve the same.

9 Replies
Anonymous
Not applicable

may be MACRO..

neetu_singh
Partner - Creator III
Partner - Creator III
Author

Can not use macro in our app

Anonymous
Not applicable

Could you share your sample data so that we can see any workaround??

mvanlutterveld
Partner - Creator II
Partner - Creator II

By creating two charts; one ASC sorted and one DESC. Apply a conditional show one both graphs, triggered by your ASC and DESC buttons.

Cheers,

Michiel

gsbeaton
Luminary Alumni
Luminary Alumni

Hi Neetu,

Yes, you could do this with an expression and a variable in your button.

The basic construct would need something like:

  • A variable that was set to 1 or 0 by your buttons.
  • An IF statement within the sort expression eg, IF(Variable,SortOrder1,SortOrder2)

The fun bit will be deciding how to control the sort.  That will depend on your data.  The first thought that comes to mind is using a Dual() function.  The second, would be using a pick(match()) array.  Both of these should be set up in your script.

Hopefully that will get you started.  If you get stuck, post here again and I'll go into more detail.

George

gsbeaton
Luminary Alumni
Luminary Alumni

Sounds like cheating, possible maintenance issues if there are a lot of these, but sometimes the simplest solutions are the best!

simenkg
Specialist
Specialist

Perhaps you can create a variabel vSortFactor. When you press DESC, set the variable to 1, when you press ASC, set the variabel to -1.

Then sort by the same expression as your main expression multiplied with the $(vSortFactor) and select order Descending.

ashfaq_haseeb
Champion III
Champion III

Hi,

Hopefully this will help you.

Perfectly Sorting Pivot Table (by A-Z. y-Value set for each dim-level)

Regards

ASHFAQ

effinty2112
Master
Master

Hi Neetu,

Try this:

Make a variable, vSortOrder and set it to 1 initially.

Make a button with text

=if($(vSortOrder)=1,'ASC','DESC')

and with an action to set the variable vSortOrder = -$(vSortOrder).

Make a variable vAscending

Match(Field, $(=Chr(39) & concat({1} Distinct Field,chr(39) & ',' & Chr(39),Field) & Chr(39)))

but replace the word Field with the name of the field you are sorting on.

In your chart sort your field by the expression

=$(vSortOrder) * $(vAscending)

Regards