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
Dual Super User
Dual Super User

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

thank you very much for your help!

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.

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 (2,770)