cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

What would an alternative to JavaScript's Reduce() be in Power Automate?

I'm fetching list items from a very simple SharePoint List using Get Items. 

 

List:

 

Annotation 2020-12-22 162028.jpg

 

I can pull the data without any issues, and I get the JSON.

II.jpg

 

The output is:

 

 

 

[
  {
    "State": "NY",
    "Person": "James"
  },
  {
    "State": "NY",
    "Person": "Kurt"
  },
  {
    "State": "SC",
    "Person": "Jose"
  },
  {
    "State": "SC",
    "Person": "John"
  },
  {
    "State": "MD",
    "Person": "Paul"
  },
  {
    "State": "FL",
    "Person": "Pedro"
  },
  {
    "State": "WA",
    "Person": "Jeane"
  }
]

 

 

 

 

I tried to use Union() to find duplicates with a Compose using union(body('Get_Data'),body('Get_Data')), but the output is exactly the same. How can I achieve the desired JSON grouping items from the same State as shown below using Power Automate?

 

 

 

{
	"NY": [{
		"State": "NY",
		"Person": "James"
	}, {
		"State": "NY",
		"Person": "Kurt"
	}],
	"SC": [{
		"State": "SC",
		"Person": "Jose"
	}, {
		"State": "SC",
		"Person": "John"
	}],
	"MD": [{
		"State": "MD",
		"Person": "Paul"
	}],
	"FL": [{
		"State": "FL",
		"Person": "Pedro"
	}],
	"WA": [{
		"State": "WA",
		"Person": "Jeane"
	}]
}

 

 

 

 

Thanks in advance.

 

 

 

1 REPLY 1
Memorable Member
Memorable Member

Hi @emfuentes27 , start here.

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (52,280)