cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerDapp2
Advocate I
Advocate I

Join of two Collections with sum up by Id

How would you try to get "D"?

 

Is there a easy solution by powerapps?

In my case, of course I have not only 2 columns, there are a few more and some differ from shop1 to shop2 , but I want them as "Details" in the main result table as well (special columns of shop 1 are empty for shop 2)...

 

PowerDapp2_0-1593088372652.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @PowerDapp2 :

I strongly agree with @gabibalaban .My code is a little bit different from his, used to solve the "=0" problem.

Add a button and set it's OnSelect property to:

 

ClearCollect(
    IceCreamAll;
    IceCream1;
    IceCream2
);
ClearCollect(
    collectionD;
    ShowColumns(
        AddColumns(
            GroupBy(
                IceCreamAll;
                "Flavor";
                "Group"
            );
            "Quantity";
            Sum(
                Group;
                Quantity
            );
            "Min";
            If(
                CountRows(Group) = 1;
                0;
                Min(
                    Group;
                    Quantity
                )
            );
            "Max";
            Max(
                Group;
                Quantity
            )
        );
        "Flavor";
        "Quantity";
        "Min";
        "Max"
    )
)

 

1.JPG

Best Regards,

Bof

View solution in original post

3 REPLIES 3
gabibalaban
Super User II
Super User II

I think you can use this formula:

 

ClearCollect(FinalTable,AddColumns(GroupBy(IceCreamAll,"Flavor","Result"),"Quantity",Sum(Result,Quantity),"Min",Min(Result,Quantity),"Max",Max(Result,Quantity)))

 

It not solve the problem with min=0 when you have only one flavor record (like choco and pistachio) but you can work on it. 

v-bofeng-msft
Community Support
Community Support

Hi @PowerDapp2 :

I strongly agree with @gabibalaban .My code is a little bit different from his, used to solve the "=0" problem.

Add a button and set it's OnSelect property to:

 

ClearCollect(
    IceCreamAll;
    IceCream1;
    IceCream2
);
ClearCollect(
    collectionD;
    ShowColumns(
        AddColumns(
            GroupBy(
                IceCreamAll;
                "Flavor";
                "Group"
            );
            "Quantity";
            Sum(
                Group;
                Quantity
            );
            "Min";
            If(
                CountRows(Group) = 1;
                0;
                Min(
                    Group;
                    Quantity
                )
            );
            "Max";
            Max(
                Group;
                Quantity
            )
        );
        "Flavor";
        "Quantity";
        "Min";
        "Max"
    )
)

 

1.JPG

Best Regards,

Bof

View solution in original post

thank you very much for your help!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (21,004)