
Announcements
Hi Guys... I try to make it really short.
I am trying to come from
-> this Excelfile:
https://i.imgur.com/Y0aKWmu.png
-> To this JSON File:
{
"No" : "1",
"Task" : "Clean House",
"Description" : "Cleaning",
"Repeatgroup": [
{
"Subtask_Location": "X",
"Subtask_Content": "X",
"Subtask_Status": "X"
},
{
"Subtask_Location": "Y",
"Subtask_Content": "Y",
"Subtask_Status": "Y"
},
{
"Subtask_Location": "Z",
"Subtask_Content": "Z",
"Subtask_Status": "Z"
}
],
"Date" : "11/04/19",
"Time" : "00:00"
}
My Problem is, that I don't know how to build the Repeatgroup of the JSON file.
I hope I explained it good. Sorry for bad english, not a native speaker...
ANY Help is appreciated very much... For fast and effective help I will give out Tip-Money, since I am so clueless right now and need this to be done. :)) Thank you in Advance
Hi @Julian1,
I create a whole Flow process that gets the row of Excel file, then create a JSON file for each No.
For the Repeatgroup, you could initialize a variable named Repeategroup, and you can see more details on step 4:
This is my whole steps of the Flow:
image 1: all steps
image 2: all steps
Step 1: (image 1)
Initialize variables Clean (to store JSON data), Repeatgroup (to store repeat group) and ALLNo ( to store ALL No, including repeat No), then get the list rows present in a table.
Step 2: (image 2)
Add apply to each and Append to array actions to get the all No of the rows
Step 3: (image 3)
Add expression union(variables('ALLNo'),variables('ALLNo')) into the Big Apply to each No action to get each No and loop it. Then add Apply to each row of table action to get all rows with the same No, append the Repeategroup. After that, we can get Repeategroup array like:
[
{
"Subtask_Location": "X",
"Subtask_Content": "X",
"Subtask_Status": "X"
},
{
"Subtask_Location": "Y",
"Subtask_Content": "Y",
"Subtask_Status": "Y"
},
{
"Subtask_Location": "Z",
"Subtask_Content": "Z",
"Subtask_Status": "Z"
}
]
Image 3:
Step 4: (image 4)
Add Apply to each row of table-2 action to get rows with same No, set the clean variable as below, since the date in Excel file will return a number that since 1899-12-30, so we should use the addDays function to get the right format:
addDays('1899-12-30', int(item()?['Date']), 'yyyy-MM-dd')
Then create JSON file.
Image 4:
Step 5:
After creating a JSON file with the same No, empty the variable Clean and Repeatgroup.
For the situation that step 4 will fail when some date value is empty, so we should configure the Set variable Repeategroup Null action setting as when the previous step has failed:
Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.