web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collating multiple for...
Power Apps
Answered

Collating multiple formulas into one

(0) ShareShare
ReportReport
Posted on by 364

Morning all,

 

So I've managed to get a set of formulas working on a a gallery that creates a set of related items based on what is in the gallery above, like so (apologies for the flexible height gallery making it look weird):

 

9.PNG

When the glossary items change, so do the related items. It's taking every term in the top gallery, analysing it against a set of terms in a glossary data set (separated by ";") and returning the other items that also contain the same glossary term. This is done via the glossary button running this:

 

ClearCollect(
 seeAlsoPre,
 ForAll(
 'Glossary Items Gallery'.AllItems,
 Ungroup(
 ForAll(
 Trim(Split(Category, ";")),
 Trim(Split(Result,";"))),
 "Value"
 )
 )
);


Clear(seeAlso); ForAll(seeAlsoPre, Collect(seeAlso, Value))

 

The top collection (seeAlsoPre) is doing what i said above and finding the relevant items. This then drops them into an arrayed collection, which the second collection is then changing into a table of single values. The related items gallery then has this code:

 

Distinct(Filter(seeAlso, Not(IsBlankOrError(Result)), Not(Result in suggested.Title)),Result)

 

This bringing back a distinct list of non blank items that are not the same as the item current selected (i.e. in the screenshot above we are on the KPI item, so the gallery of related items is omitting KPI from the terms as it would just be linking to itself).

 

Now, due to trying to improve the interface a little, which isn't relevant, I was hoping someone might be able to instruct me how to aggregate all this code into the Items code for the related item gallery, so that I'm not creating collections and the like?

 

Cheers!

 

Matt

 

Categories:
I have the same question (0)
  • EpicTriffid Profile Picture
    364 on at

    Hello all,

     

    Hoping someone might have thought of a solution?

  • Verified answer
    EpicTriffid Profile Picture
    364 on at

    I worked it out!

     

    Distinct(
     Filter(
     Ungroup(
     ForAll(
     'Glossary Items Gallery'.AllItems,
     Ungroup(
     ForAll(
     Trim(Split(Category,";")),
     Trim(Split(Result,";"))
     ),
     "Value"
     )
     ), 
     "Value"),
     Not(IsBlankOrError(Result)), Not(Result in suggested.Title)),
     Result
    )

     

    For anyone interested, or if you come across this kind of thing, I was trying to replicate my original code by running the ForAll here:

    Clear(seeAlso); ForAll(seeAlsoPre, Collect(seeAlso, Value))

    around the other ForAll here:

    ClearCollect(
     seeAlsoPre,
     ForAll(
     'Glossary Items Gallery'.AllItems,
     Ungroup(
     ForAll(
     Trim(Split(Category, ";")),
     Trim(Split(Result,";"))),
     "Value"
     )
     )
    );

    Essentially, I was removing the collect functions and trying to mush them together, but it just wasn't working. Then I realised that Ungroup flattens a table, so I ran that around my original code, and was able to splice in my Distinct and Filter functions too! Basically, just use Ungroup to flatten a nested table!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard