Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Collating multiple formulas into one

(0) ShareShare
ReportReport
Posted on by 345

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

 

  • Verified answer
    EpicTriffid Profile Picture
    345 on at
    Re: Collating multiple formulas into one

    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!

  • EpicTriffid Profile Picture
    345 on at
    Re: Collating multiple formulas into one

    Hello all,

     

    Hoping someone might have thought of a solution?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard