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 / Two Collections and jo...
Power Apps
Answered

Two Collections and join n:m to one (new) collection

(0) ShareShare
ReportReport
Posted on by 7

Hello all,

I have the following challenge. I need to make two collections into one. But I need to keep the behavior of a n:m relationship.

Here is a mini-example creates two new collections group_m and group_n:
ButtonA:

 

ClearCollect(
 group_m;
 {
 gm_nr: 1;
 gm_atribut: "Hello"
 };
 {
 gm_nr: 2;
 gm_atribut: "Hallo"
 };
 {
 gm_nr: 2;
 gm_atribut: "Gutentag"
 };
 {
 gm_nr: 3;
 gm_atribut: "Moin"
 }
);;
ClearCollect(
 group_n;
 {
 gn_nr: 1;
 gn_atribut: "Foo"
 };
 {
 gn_nr: 1;
 gn_atribut: "Bar"
 };
 {
 gn_nr: 2;
 gn_atribut: "Christian"
 }
);;

 

ButtonB should merge them into a new collection like the following example:

 

Collect(
 group_m_n;
 {
 gm_nr: 1;
 gm_atribut: "Hello";
 gn_nr: 1;
 gn_atribut: "Foo"
 };
 {
 gm_nr: 1;
 gm_atribut: "Hello";
 gn_nr: 1;
 gn_atribut: "Bar"
 };
 {
 gm_nr: 2;
 gm_atribut: "Hallo";
 gn_nr: 2;
 gn_atribut: "Christian"
 };
 {
 gm_nr: 2;
 gm_atribut: "Gutentag";
 gn_nr: 2;
 gn_atribut: "Christian"
 };
 {// Blank or without this Dataset: gm_nr: 3
 gm_nr: 3;
 gm_atribut: "Moin";
 gn_nr: Blank();
 gn_atribut: Blank()
 }
);;

 

 Which is the easiest way?

Categories:
  • timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    @VionMichael 

    It looks like you're trying to do a full cartesian join. The approach I would take would be to nest a call to ForAll inside another call to ForAll, like @PowerAddict describes here.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Cross-join-or-Cartesian-Join-of-collections/m-p/517720

     

  • VionMichael Profile Picture
    7 on at

    Thanks for your answer.

     

    I need (unfortunately) not every combination, as requested in the question from the link.
    But only the respective combinations if the gm_nr (Collection: group_m) and the gn_nr (Collection: group_n) are identical.

  • Verified answer
    timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    Hi @VionMichael 

    You can do this by filtering the nested ForAll to return only those records where gm_nr=gn_nr. Provided it's acceptable to completely skip gm_nr, the formula would look like this:

     

    ClearCollect(
     group_m_n;
     Ungroup(
     ForAll(
     group_m;
     ForAll(
     Filter(
     group_n;
     gm_nr = gn_nr
     );
     {
     gm_nr: gm_nr;
     gm_atribut: gm_atribut;
     gn_nr: gn_nr;
     gn_atribut: gn_atribut
     }
     )
     );
     "Value"
     )
    )

     

    timl_0-1634587045977.png

     

  • VionMichael Profile Picture
    7 on at

    Hello,
    sorry for the late response, but that looks very good.
    Thanks for that.

    Unfortunately, the zero value is not included, but that's a 'nice to have' in my case.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard