cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bpplls
Helper II
Helper II

Nested JSON - Get Distinct "tags" by id

Hi All,

 

I have a JSON file and I want to get the Distinct "tags" of the user ID and display it on the Items property of the dropdown.

"tags" is in an array format.

 

Sample JSON generated from getting the ID of the user.

bpplls_0-1658725685333.png

 

Sample code in the dropdown Items property.

bpplls_1-1658725793331.png

 

How can I display the values of these two Result?

Thanks in advance.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
iAm_ManCat
Super User
Super User

Heya,

 

To account for any number of potential tags per item you have to get a bit wizardy:

 

 

With(
    {
        ConcatText: 
        //Get a text string containing all tag items
        Concat(
            ForAll(
                projed,
                Concat(
                    ThisRecord.Value.tags,
                    Value & ";"
                )
            ),
            Value
        )
    },
    Distinct(
        //Split the text string into items which then can be made distinct
        Split(
            //Don't include last ; so that no blank items
            Left(
                ConcatText,
                Len(ConcatText) - 1
            ),
            ";"
        ),
        Result
    )
)

 

 

Included a POC App here for you to download - might be worth playing around with that to see if it will help 🙂

 

Cheers,

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

2 REPLIES 2
shoog
Dual Super User
Dual Super User

Is it possible the JSON includes two id's or will it always be one?

If it's always just one, you could use

Distinct(First(collIt2).tags,Value).Result

 

iAm_ManCat
Super User
Super User

Heya,

 

To account for any number of potential tags per item you have to get a bit wizardy:

 

 

With(
    {
        ConcatText: 
        //Get a text string containing all tag items
        Concat(
            ForAll(
                projed,
                Concat(
                    ThisRecord.Value.tags,
                    Value & ";"
                )
            ),
            Value
        )
    },
    Distinct(
        //Split the text string into items which then can be made distinct
        Split(
            //Don't include last ; so that no blank items
            Left(
                ConcatText,
                Len(ConcatText) - 1
            ),
            ";"
        ),
        Result
    )
)

 

 

Included a POC App here for you to download - might be worth playing around with that to see if it will help 🙂

 

Cheers,

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,530)