ContributionsMost RecentMost LikesSolutionsRe: Split hours into back dated days based on total hours Thank you @koryknick This makes sense. Depending on a script was definitely one of the options (and we managed to get this done with the help of a JavaScript). Just thought to share this in the community and understand if there’s a way to get this done in SnapLogic directly. Regards, Tanmay Split hours into back dated days based on total hours Hello All, I’ve stumbled upon a scenario, where I need to split the JSON object into n number of objects (backdated) if the total hours coming in from the source crosses 24, it should split until the point the total hours have been exhausted. I have added an input JSON array for clarifying my requirement: [ { "res": "1001", "activity": "First", "hours": "20", "date": "31/01/2022" }, { "res": "1001", "activity": "Second", "hours": "8", "date": "31/01/2022" } ] For res 1001 the total hours gathered from both the activities is 28 hours, which is crossing the threshold of 24 hours for a day, what I would like to achieve is to split any one of the object in such a way that the remaining hours (4 hours → 28-24) gets spread across another object for the previous day. Here is the desired output: [ { "res": "1001", "activity": "First", "hours": "20", "date": "31/01/2022" }, { "res": "1001", "activity": "Second", "hours": "4", "date": "31/01/2022" }, { "res": "1001", "activity": "Second", "hours": "4", "date": "30/01/2022" } ] Had the total hours in input be 60 hours then the output would be required to split across 3 days. 24 + 24 + 12, let’s say activity 1 has 24 hours for date 31/01/2022, activity 2 has 24 hours for 31/01/2022 and activity 3 has 12 hours for date 31/01/2022, then activity 2 would have to shift back to 30/01/2022 and activity 3 would have to shift back to 29/01/2022 as activity 2 has occupied 24 hours on 30/01/2022. Hope this makes sense. Activities will always have the current day’s date (whenever this calculation will occur). Any help on this would be greatly appreciated, thank you in advance. Regards, Tanmay SolvedRe: Group by fields with specific group size Thanks a lot @ptaylor we are yet to discover and test the new feature of Group By Fields snap post November 4.27 release, but the lucid explanation given by you is going to help incredibly. I am going to share this with my team. Re: Merge objects into first element of the group Thanks a lot @spinaka, this is really helpful. Gets the job done elegantly only with the help of a mapper. Re: Group by fields with specific group size Hello @Spiro_Taleski Thank you for suggesting this. This seems to be the quickest and the simplest solution to get this done. Thanks, Tanmay Re: Merge objects into first element of the group Thanks a lot @bojanvelevski this worked. Tweaked this a bit to get the solution we are looking for. Group by fields with specific group size Hello All, Is there a way we can use group by fields limited to a group size? Group by fields snap doesn’t let us specify a group size, so if we try to create groups based on a field, whether the occurrence of the field is 5 times or 500 times, output of group by fields snap would always be one group with all the object with that one common field together. What if we want to create different groups with similar field of similar size. For instance, if there is a field called ‘id’ with value ‘5’ and it occurs 20 times in an input, can we create 4 groups out of it with each group containing 5 values. If it were 22, it should create 5 groups. This is like using group by N and group by field snap together. Any suggestions or help on this would be really great. Thank you. SolvedMerge objects into first element of the group Hello All, I have stumbled upon a scenario where we need to map all the elements within an array to the first element of the object or if we have to simplify the use case based on a certain field we have to merge all the elements together. The examples attached will give more clarity. Input: { "group": [ { "projectNum": "1234", "projectName": "Abc", "taskNum": "111", "taskName": "Task1" }, { "projectNum": "1234", "projectName": "Abc", "taskNum": "222", "taskName": "Task2" }, { "projectNum": "1234", "projectName": "Abc", "taskNum": "333", "taskName": "Task3" } ] } Output: { "group": [ { "projectNum": "1234", "projectName": "Abc", "tasks": [ { "taskNum": "111", "taskName": "Task1" }, { "taskNum": "222", "taskName": "Task2" }, { "taskNum": "333", "taskName": "Task3" } ] } ] } Since the projectNum and projectName across all objects will remain the same, we need to merge all the tasks related keys to the first object of the group or reduce the objects in such a way that only one element is left in the array with common project information with the task array attached to that element. Note: projectNum and projectName will always be common across all the objects in the input array as we are grouping based on projectNum before sending the data to mapper for this specific transformation. We tried our luck with reduce operation but couldn’t really fetch out a solution, any suggestions on this would be really helpful. Thank you. SolvedRe: Sum of values in array of objects without reduce function @koryknick Thanks a lot, eventually map and merge function helped. Re: Sum of values in array of objects without reduce function @bojanvelevski Thanks a lot, I never realized Apache Velocity can be used within JSON generator in such a way, this would come in handy in future.