83
Views
6
Comments
Solved
How to append a list of specific structure?

I have a list called "List 1" and its structure is (below)

[

    {

        "SeriesName": "Machine",

        "Datapoints": [

            {

                "Label": "Emerald",

                "Value": 1

            },

            {

                "Label": "Sapphire",

                "Value": 1

            },

            {

                "Label": "Sapphire ",

                "Value": 1

            }

        ]

    }

]
I need to create another variable of same structure but i want to group all the labels of same name and assign the value to its total number of count on the same label name.. like this(below)


[

    {

        "SeriesName": "Machine",

        "Datapoints": [

            {

                "Label": "Emerald",

                "Value": 1

            },

            {

                "Label": "Sapphire",

                "Value": 2

            }

         

        ]

    }

]

2025-03-11 17-46-55
Tiago Dias
Solution

Hi Joe,

Please check the attached OML containing a working version.
Note that you have a space in the second "Sapphire " label. To avoid misbehaviors, I've added TRIM to the expressions.
You can play around with a playground interface:

João, note that when using Distinct over a structure, every single field of the structure must be different.
If you have an item Saphire:4 you ended with Saphire being duplicated in the output list. I believe that solution would only work if Value was always 1 for each single DataPoint.

Regards,
Tiago.



CommunityHelpApp.oml
2024-04-05 19-22-12
João Sousa

Hi Tiago.

Thanks for the tip! I know and it was an assumption as I stated in the comments. if not you would have just to differentiate labels first as I said in the comment, as probably you have done (I commented it on the code how to do it, but had no time to implement that part)! Thank you for your tip, help and solution! :D

2023-07-20 11-15-41
Joe AJ

Hi Tiago
Thank you so much. That works perfectly! I marked it as solution

2024-04-05 19-22-12
João Sousa

Hi there, 

One possible approach:

You can have another list with that structure, and then filter the first list by label, for each label. you'll then append the length of that list on the second list, with tha current label value.

If it's not clear, I can show you on an .oml

Kind Regards,

João


2023-07-20 11-15-41
Joe AJ

Hi Joao.Thank you so much for the quick response.If possible can you please share me an .oml.I tried all the possible ways.but somehow i end up with wrong value!

2024-04-05 19-22-12
João Sousa


Here's a possible approach with comments.

Feel free to ask for anything, or correct it if I assumed something wrong :)

Hope it helps,

Kind Regards,

João

sample.oml
2025-03-11 17-46-55
Tiago Dias
Solution

Hi Joe,

Please check the attached OML containing a working version.
Note that you have a space in the second "Sapphire " label. To avoid misbehaviors, I've added TRIM to the expressions.
You can play around with a playground interface:

João, note that when using Distinct over a structure, every single field of the structure must be different.
If you have an item Saphire:4 you ended with Saphire being duplicated in the output list. I believe that solution would only work if Value was always 1 for each single DataPoint.

Regards,
Tiago.



CommunityHelpApp.oml
2024-04-05 19-22-12
João Sousa

Hi Tiago.

Thanks for the tip! I know and it was an assumption as I stated in the comments. if not you would have just to differentiate labels first as I said in the comment, as probably you have done (I commented it on the code how to do it, but had no time to implement that part)! Thank you for your tip, help and solution! :D

2023-07-20 11-15-41
Joe AJ

Hi Tiago
Thank you so much. That works perfectly! I marked it as solution

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.