cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlexTheKidd
Resolver I
Resolver I

Compare all items in Gallery to check for the same ID or Blank

I've spent the last 1.5 working days trying to search the forums, but I am yet to find something that works for me.

I have a collection where I am trying to check whether all IDs in the collection are either the same or blank - if not, then it cannot continue.

The app can consolidate different items together - however, the I'm experiencing is that I cannot figure out how to compare the ConsolidationID to each other.

 

Example for 3 items:

Title        |   ConsolidateID

A             |       ABC

B             |       ABC

C             |       CBA

 

If the button to consolidate these titles together, a notification would appear, but let's say that the ID for C is blank, then it would consolidate the items (the consolidation ID is auto-generated in the app).

I just cannot figure out how to compare all the different IDs to each other.

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
AlexTheKidd
Resolver I
Resolver I

Holy maloney... I asked ChatGDP "check if ID is the same or blank in gallery in Powerapps", which answered the following:

 

If(CountRows(Filter(Gallery.AllItems, IsBlank(ID) || ID = First(Gallery.AllItems).ID)) = CountRows(Gallery.AllItems), "All IDs are the same or blank", "IDs are not all the same or blank")

 

The code works, as it now compares all IDs that they are the same, or that they are blank. Here is the code I'm using, which works as it should:

If(
    CountRows(
        Filter(
            Gallery_consolidate.AllItems,
            IsBlank(ConsolidatedID) || ConsolidatedID = First(Gallery_consolidate.AllItems).ConsolidatedID
        )
    ) = CountRows(Gallery_consolidate.AllItems),
    formula...,
    formula....
)

View solution in original post

3 REPLIES 3
Bilakanti
Power Participant
Power Participant

@AlexTheKiddCan you try using GroupBy

 

AlexTheKidd
Resolver I
Resolver I

Hi @Bilakanti ,

 

When using GroupBy (and ClearCollect), I do get the consolidated ID's grouped together, but I'm still not sure how I can compare all the items.

In the example below, there is 1 blank, 2 with the top ID, and 1 with the bottom - I should not be able to consolidate these, as they have to either be the exact ID, or blank.

I guess I could count the number of items in the collection, but if I didn't have any blanks, and two different ID's, it would proceed, when it should not.

AlexTheKidd_0-1675064703237.png

 

AlexTheKidd
Resolver I
Resolver I

Holy maloney... I asked ChatGDP "check if ID is the same or blank in gallery in Powerapps", which answered the following:

 

If(CountRows(Filter(Gallery.AllItems, IsBlank(ID) || ID = First(Gallery.AllItems).ID)) = CountRows(Gallery.AllItems), "All IDs are the same or blank", "IDs are not all the same or blank")

 

The code works, as it now compares all IDs that they are the same, or that they are blank. Here is the code I'm using, which works as it should:

If(
    CountRows(
        Filter(
            Gallery_consolidate.AllItems,
            IsBlank(ConsolidatedID) || ConsolidatedID = First(Gallery_consolidate.AllItems).ConsolidatedID
        )
    ) = CountRows(Gallery_consolidate.AllItems),
    formula...,
    formula....
)

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (4,630)