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

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
v-micsh-msft
Community Support
Community Support

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
v-micsh-msft
Community Support
Community Support

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

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

 

Thank you!

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 ?

@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.
Check out my PowerApps Videos too!

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)

!

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

@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.
Check out my PowerApps Videos too!

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
        }
    )
)

@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.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (59,621)