cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
spyderbuilt
Level: Powered On

Display Data from multi level collection

I have created a collection based on a json flow response that has created a multi level collection. I am looking for help in trying to access data nested 3 levels deep in the collection. For instance I have a collection called colFaceData > responses > webDetection > bestGuessLabels > label

 

I am trying to access the value in label. I have attached the schema, and example response, and a screenshot of my collection.

 

How would I first assign a gallery to the bestGuessLabels collection and then assign the text value of a label control with the "label" value?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Display Data from multi level collection

Hi @spyderbuilt,

 

Just from the output data, the Gallery items property should be set to:

First(first(ColFaceData).Response).webDetection.bestGuessLabels

Then under the Text property of the Label control, set to:

ThisItem.Label

Let me know if this works.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Community Support Team
Community Support Team

Re: Display Data from multi level collection

Hi @spyderbuilt,

 

Just from the output data, the Gallery items property should be set to:

First(first(ColFaceData).Response).webDetection.bestGuessLabels

Then under the Text property of the Label control, set to:

ThisItem.Label

Let me know if this works.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

spyderbuilt
Level: Powered On

Re: Display Data from multi level collection

Sorry for the late response but that worked great. I thought I would be limited by the collection being too deep.

 

Thank you!

Super User
Super User

Re: Display Data from multi level collection

Hi @v-micsh-msft , 
How can I display this type of thing for a DropDown Control? 
Schema of API call:

{
  "type": "object",
  "properties": {
    "features": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "attributes": {
            "type": "object",
            "properties": {
              "OBJECTID": {
                "type": "integer"
              },
              "OPERATION_NAME": {
                "type": "string"
              },
              "REGION_NAME": {
                "type": "string"
              },
              "LOCATION_NAME": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "attributes"
        ]
      }
    }
  }
}

Collection: colV2Flow.features.attributes (digging into the response a layer)

Goal:  To have all LOCATION_NAME's available in a DropDown Control

DropDown.Items tried so far:

  • `collectionName.attributes`
    • Result: Error
    • image.png
  • `First(colV2FLOW.attributes).attributes`
    • Result: Only brings back the first LOCATION_NAME
  • `Ungroup(colV2FLOW), "LOCATION_NAME")`
    • Result: " The specified column "LOCATION_NAME" does not exist."

I want to control this within PowerApps to keep things simple. Do not want to use Flow if possible. Any ideas @RandyHayes and @v-xida-msft ?

Super User
Super User

Re: Display Data from multi level collection

@ericonline 

I'm not sure if you are trying to get a table of LOCATION_NAME values that might be in that property, or if you are trying to get all LOCATION_NAME values across all possible results.

 

One quick action for that structure having multiple records would be a formula such as this:

ClearCollect(locations, 
  ForAll(yourCollection.properties, properties.features.items.properties.attributes.properties.LOCATION_NAME))

Again, not sure of your final data and what might be in it, but in this sample, we're collecting all the location names into a collection.

 

Hope that give some guidance.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Display Data from multi level collection

Bro... you are batting 1000 today! Thank you so much, sincerely. You rock man!
Went with:

ClearCollect(
    colLocations, 
    ForAll(
        collectionName.attributes, 
        attributes.LOCATION_NAME
    )
)

Dropdown:

Distinct(colLocations.Value, Value)

!

Super User
Super User

Re: Display Data from multi level collection

Adding to the Body of Knowledge here... I couldn't figure out how to use the above to grab 2 or more attributes. 

Tried:

ClearCollect(
    colLocations, 
    ForAll(
        collectionName.attributes, 
        attributes.LOCATION_NAME && attributes: THING1_NAME
    )
)

Had to rearrange things a bit to:

ForAll(
    collectionName.attributes, 
    Collect(
        colLocationsAndThing1,
        {
            location: attributes.LOCATION_NAME,
            thing1: attributes.THING1_NAME
        }
    )
)

This worked well! Thanks again

Highlighted
Super User
Super User

Re: Display Data from multi level collection

@ericonline 

I think your first try was closer...

 

ClearCollect(
    colLocations, 
    ForAll(
        collectionName.attributes, 
        {location: attributes.LOCATION_NAME,
thing1: attributes.THING1_NAME
} ) )

If not closer...just a little easier on the eyes perhaps...

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Display Data from multi level collection

Interesting! I've not experimented with ForAll very much. 
These both return the same tables:

ForAll(
    collectionName.attributes, 
    Collect(
        colLocationsAndThing1,
        {
            location: attributes.LOCATION_NAME, 
            thing1: attributes.THING1_NAME
        }
    )
);

ClearCollect(
    colLocationsAndThing1_TEST,
    ForAll(
        collectionName.attributes,
        {
            location: attributes.LOCATION_NAME,
            thing1: attributes.THING1_NAME
        }
    )
)
Super User
Super User

Re: Display Data from multi level collection

@ericonline 

Yes, thing to note...ForAll returns a collection (or a table of records)!

So, in the first one, you are iterating over collectionName.attributes and for each one, you are Collecting a record in the colLocationsAndThing1 collection.

In the second one, you are iterating over the collectionName.attributes again, but this time ForAll is building a table of records, that table of records then gets assigned (collected) to the colLocationsAndThing1_Test collection.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,123)