I have a list called "List 1" and its structure is (below)
[
{
"SeriesName": "Machine",
"Datapoints": [
"Label": "Emerald",
"Value": 1
},
"Label": "Sapphire",
"Label": "Sapphire ",
}
]
]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)
"Value": 2
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.
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
Hi TiagoThank you so much. That works perfectly! I marked it as solution
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
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!
Here's a possible approach with comments.
Feel free to ask for anything, or correct it if I assumed something wrong :)
Hope it helps,