web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Transform Excel Table ...
Power Automate
Unanswered

Transform Excel Table to a JSON with an embedded Array / Repeatgroup

(0) ShareShare
ReportReport
Posted on by 6

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.

  • The reference/indicator is the "No" Field in the Excel-File...
  • So the Values of the 3 "Subtask_..."-Columns need to get written as the Repeatgroup, because of the same "No." (First column) as an indicator...

 

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

Categories:
I have the same question (0)
  • Verified answer
    v-litu-msft Profile Picture
    on at

    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

    Annotation 2019-09-26 153440.pngimage 2: all stepsAnnotation 2019-09-26 153609.png

    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:

    Annotation 2019-09-26 153741.png

    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: 

    Annotation 2019-09-26 153804.png

     

    Step 5:

    After creating a JSON file with the same No, empty the variable Clean and Repeatgroup.Annotation 2019-09-26 153842.png

    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:Annotation 2019-09-26 160721.png

     

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard