Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to customize sort order using drop down in a macro

spencer_scott
5 - Atom

Hi I am struggling with some logic I thought would work based off other examples I've seen and things I've put together in the past, but it doesn't seem to be working as it should. I'm trying to change the sort order on the Sort tool inside a macro where the user selects a scenario and the macro will handle Ascending/Descending dynamically on multiple Sort Tools based on the users selection.

 

My drop down is setup as follows:

desktop-hvrsbq3.png

I have the drop down setup with multiple Action tools configured to "Update Value with Formula" pointing at the same Sort tool section @order - value="Ascending" and I'm trying to change the sort order dynamically based on the user selection. I also have another Sort tool further downstream that will be changed to possibly be the same as this Sort tool or different depending on the scenario selected.

 

For example:

- low = Ascending

- high = Descending

- low_high = Ascending on 1st Sort tool, Descending on 2nd Sort tool

- high_low = Descending on 1st Sort tool, Ascending on 1st Sort tool

desktop-hvrsbq3.png

 I've also done the formula as the following style and it doesn't work either.

 

 

IF [#1] = 'high' THEN "Descending" ELSE NULL() ENDIF

 

 

 

 

 

5 REPLIES 5
Hollingsworth
12 - Quasar
12 - Quasar

My guess is that the @order - value item must have a value, it can't be null.

 

What comes to mind is using a detour (or rather a set of them) that would shunt the data stream to one of four pre-configured Sort tools.

John Hollingsworth
Clear Channel Outdoor
apathetichell
18 - Pollux

This does what you want - set up first action/sort combo for:

switch(tonumber([#1]),'Ascending',1,'Ascending',2,'Descending',3,'Ascending',4,'Descending')

 

for the second one you'd use:

switch(tonumber([#1]),'Ascending',1,'Ascending',2,'Descending',4,'Ascending',3,'Descending')

 

and the name:value are set to

Ascending:1
Descending:2
Up-Down:3
Down-up:4

 

see attached for the workflow implementation - obviously this is only testable in this form on the third and fourth options...

 

@HollingsworthHave you seen the thread on .mif files? As the local spatial genius -  I know that you'd be able to point the poster in the right direction.

apathetichell
18 - Pollux

Hi @spencer_scott have you had a chance to use my workflow - and if so could you mark my solution as correct so the next time someone is trying to implement a sort selector it pops up faster? Thanks!

spencer_scott
5 - Atom

Wow thank you so much @apathetichell that was such a simple solution. I created a couple of separate workflows to solve the immediate problem last week before I could come back and test your suggestion. I've since used your suggestion and added even more scenarios as the switch() formula was perfect for my use case. Thank you!

apathetichell
18 - Pollux

Great to hear!

Labels