What is the best way to sort the list items
Hi All,
In which way we can sort the list items names and suggest me in an optimized way which wont increase the model size.
Thanks in advance!!
Regards,
Mahesh Kumar.
Answers
-
HI Mahesh,
My suggestion is to create a module with that list and create one line item with "Text" formatted and bring in the Name into that line item by writing Name(Item('')) if it is a normal list or Display Name.List if it is a numbered list. Then put Sorting on the above created line item either in Ascending or Descending order based on your requirement. Please have a quick look at the below screen shot.
Before Sorting
Sorting based on Line item "Name"
After sorting,
Let me know if you want any clarifications.
Thanks,
Kavin.2 -
Thanks Kavin,
But if i a have more properties and the data is coming through other integrations.And after sorting in the module i need to import to the list.
But after some days if the list get updated with other names and again we need to run the import action again.
These way the model size increases more.
Is there any other way to sort the items in list.1 -
HI Mahesh,
Try it in this way.
Step 1: Create a List called "Alphabetical Order" and create all the 26 characters as a list items with code starts from 0 to 26. ( Note :This will be a one time actvity) You can use this for any list that needs to be sorted.
Step 2: Create a line item in your module(Would always prefer because of Model performance and don't create properties) and it should be number formatted. The module should have the dimension of the list that you needs to get it sorted. Then write the below formula and sort that accordingly (Basically create relation between your list and Alph.. List and convert that to number) .
Before sorting.
After sorting.
So in this way you can do your sorting permemantly without any increase in Model size as well. You can use that list "Alphabetaical Order" for whatever list that you want to sort.
Thanks and let me know if you have any concerns. I hope this would be helpful!! 🙂
Kavin.
4 -
Hi Kavin,
I like the idea and it works neatly if you want it "loosely" sorted on alphabetical order.
However, in this solution, there's no "ranking bias" given to the second (and third, fourth etc.) letters - Sri Lanka appears above Sri Lanka.
I'm looking to get my head around a similar solution, but for alphanumerical list items (account IDs - "AC12354" etc.).
Does anyone have a thought on this?
1 -
Hi
You can add more formulas like this to rank to 3 letters:
VALUE(CODE(FINDITEM(Alpha Order, LEFT(Unique Employee.EmployeeName[LOOKUP: Employee Name], 1))) & CODE(FINDITEM(Alpha Order, MID(Unique Employee.EmployeeName[LOOKUP: Employee Name], 2, 1))) & CODE(FINDITEM(Alpha Order, MID(Unique Employee.EmployeeName[LOOKUP: Employee Name], 3, 1)))) / 100
0 -
For performance, please split those component parts out into separate line items
Unique Employee.EmployeeName[LOOKUP: Employee Name] is repeated 3x
and you should split the parameters of the FINDITEM into separate line items too
David
0 -
Quick question.
you said to repeat Unique Employee.EmployeeName[LOOKUP: Employee Name] x 3 times.
This formula will provide the same results 3 times so why do I need to do 3 times?
0 -
sorry for the confusion, I meant because it is repeated 3x in the formula, it should be split out into a single line item
David
0 -
Hi,
You could use the alphabetical order give by the names using a text formatted Line item named Sort and a formula like:
Upper(Name(Item('List to be sorted')))
Use upper function to eliminate different ASCI codes of lower and capital letters.
If the list is multi level concatenate the Parents in the Sort line item in front of the level 0 element. below an example with 3 level list:
Upper( Parent(Parent(Name(Item('List to be sorted')))) & "_" & Parent(Name(Item('List to be sorted'))) & "_" & Name(Item('List to be sorted')) )
This way the order will be shown respecting the hierarchy and also the parents in the hierarchy will be ordered.
2 -
I would ask basic questions,
Why is the sorting need to be in the List. If it is for display, you can always display the module after sorting using Text/Numeric or combination of both. I agree it is a hassle to sort every module in every dashboard. But fundamental question is why the list need to be sorted in itself.
I am not up for a "Alphabetical" list to mock the sort function based on first few characters. Not scalable.
Thanks
Arun
0 -
Hi @kavinkumar,
After sorting in the module. You applied a Boolean formula. Why is this done?
Also tell me, after sorting, how will the list get updated?
0 -
Just to say, if you haven't already found it we have released an action to automate the sorting on a list
Details can be found here
https://help.anaplan.com/anapedia/Content/Modeling/Build%20Models/Actions/Order-list.html
Hope this helps
David
1 -
Just following up on this year old post. In case you haven't seen it you can now sort list items with an action.
https://help.anaplan.com/en/7a09027d-894e-4817-9f92-1fd11d018e2a-Order-List
0 -
Hi,
I had similar situation where I had to do a sort on LIST. I tried the first option and it works when the line item is in column, however, when i have the list and line item in row (time in column) the sort is gone.. the requrement is to have list and line items in row and months in col..
Any way to work it out?
0