Hi Team,
I'm new to Alteryx and was wondering how can I sort a column based on the values of a different column?
For example, sort the Brand column descending based on the values in the Sales column.
Solved! Go to Solution.
Not sure I'm understanding the total question.
If you are asking that WITHIN the Brand column you want to sort on Sales, you can just use a Sort tool with Brand as the first sort, and Sales as the second sort.
Am I missing something? If so, can you provide an example of what you are looking for?
Sorry, formating error.
If my data looks like this (assuming column for Brand \ Item \ Sales):
Brand A - Item 1 - $10
Brand A - Item 2 - $30
Brand B - Item 3 - $100
Brand B - Item 4 - $25
Brand C - Item 5 - $80
And I want it to look like:
Brand B - Item 3 - $100
Brand B - Item 4 - $25
Brand C - Item 5 - $80
Brand A - Item 2 - $30
Brand A - Item 1 - $10
The Sort Tool allows to sort only alphabetically?
It looks like you are sorting on the brand based on the maximum item within that brand...in other words, the brand with the largest item should be first regardless of any other items within the brand? (So it's the 100, 80, and 30 that matters.)
Or is it the sum of all items in the brand that determine the sort? (So it's the 125, 80, and 40 that matters...i.e., the sum of the brand.)
Actually in either case, what I think you need to do is determine the sort of the brands based on whichever of the above is correct. (So in a sense, the two sort variables are independent of each other.) To do that you would use a Summarize tool to get either the sum or the max (or sum) value grouped by the brand. You would then sort that list separately, then assign a 1 thru N rank (you can use a Record ID tool for that) for each brand, and then join that back to your original list using brand as the key. This would put a 1 for Brand B, 2 for Brand C, and 3 for Brand A.
Then you just sort the entire list using the Rank value first and the dollar value second.
I've attached an example of how this works.
As to the Sort tool only sorting alphabetically, no, but if you are sorting the dollar amount like it is, Alteryx will recognize it as a String data type (due to the dollar sign). You would need to eliminate the dollar sign and convert to a number before it will sort based on the number.
Thanks. That's exactly what I was looking for (using SUM instead of MAX). It works !!
User | Count |
---|---|
19 | |
15 | |
15 | |
9 | |
8 |