cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ryanb1
Frequent Visitor

Joining tables with GroupBy

Hi all

I want to join two tables that need to be grouped by date and summed by size. 

 

Here is the scenario: We produce t-shirts and powerapps collects the number of t-shirts (by size) we make each day and stores that data in a SharePoint list 'Hourly Count App Data' in a column called 'CountGood' (there are multiple entries a day).

 

Our packing house records the number of t-shirts (also by size) that are sent to it each day through powerapps, saved to a SharePoint list 'Packing Tees Received' in a column called 'PackingCountGood'.

 

I have created two separate tables that produce this information, using addcolumns, groupby, etc. The code for the first table and the two resulting tables are below. 

 

Hourly Count App
AddColumns( GroupBy( Filter( 'Hourly Count App', OrderID = DropdOrderID_1.Selected.Result ), "Size", "BySize" ), "CountBySize", Sum( BySize, CountGood ) )

 

Packing House Received App Data
AddColumns( GroupBy( Filter( 'Packing Tees Received App Data', PackedOrderID = DropdOrderID_1.Selected.Result ), "Size", "ByPackingSize" ), "PackingCountBySize", Sum( ByPackingSize, PackingCountGood ) )

 

 

TeesTables.JPG

I need to have a data table joined from the two different lists with three columns: 'Size', 'CountGood', and 'PackingCountGood'. The columns 'CountGood' and 'PackingCountGood' should be grouped and summed by size. This table then shows us how many t-shirts we have made in each size, and how many in each size we have sent to the packing house.

 

I have attempted to do this by adding the code from the Packing House Received to the Hourly Count table as an add column, essentially adding in the second data source and grouping and summing in the same way - see below.

 

What am I doing wrong? (I know the answer to this is probably: "a lot!") I am sure this has something to do with Primary keys, but tbh I don't really know what I am doing.

Thank you!

 

AddColumns(
        GroupBy(
            Filter(
                'Hourly Count App',
                OrderID = DropdOrderID_1.Selected.Result
            ),
            "Size",
            "BySize"
        ),
        "CountBySize",
        Sum(
            BySize,
            CountGood
        )
    ,"PackedGood",GroupBy(Filter('Packing Tees Received App Data',
                PackedOrderID = DropdOrderID_2.Selected.Result
            ),
            "Size",
            "ByPackingSize"
        ),
        "PackingCountBySize",
        Sum(
            ByPackingSize,
            PackingCountGood
        )
    ),))

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Joining tables with GroupBy

Hi @ryanb1 ,

Based on the formula you provided, I think there is something wrong with it. I think it is not necessary to add two GroupBy functions to achieve your needs.

 

I have made a test on my side, please consider take a try with the following workaround:

Add a Data Table control within your app, set the Items property to following:

 

DropColumns(
RenameColumns(
AddColumns( RenameColumns(
GroupBy( Filter( 'Hourly Count App', OrderID = DropdOrderID_1.Selected.Result ), "Size", "BySize" ),
"Size",
"Size1"
), "CountBySize", Sum(BySize, CountGood),
"PackedGood",
Sum(Filter('Packing Tees Received App Data', PackedOrderID = DropdOrderID_2.Selected.Result, Size = Size1), PackingCountGood)
),
"Size1",
"Size"
),
"BySize"
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support
Community Support

Re: Joining tables with GroupBy

Hi @ryanb1 ,

Based on the formula you provided, I think there is something wrong with it. I think it is not necessary to add two GroupBy functions to achieve your needs.

 

I have made a test on my side, please consider take a try with the following workaround:

Add a Data Table control within your app, set the Items property to following:

 

DropColumns(
RenameColumns(
AddColumns( RenameColumns(
GroupBy( Filter( 'Hourly Count App', OrderID = DropdOrderID_1.Selected.Result ), "Size", "BySize" ),
"Size",
"Size1"
), "CountBySize", Sum(BySize, CountGood),
"PackedGood",
Sum(Filter('Packing Tees Received App Data', PackedOrderID = DropdOrderID_2.Selected.Result, Size = Size1), PackingCountGood)
),
"Size1",
"Size"
),
"BySize"
)

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
ryanb1
Frequent Visitor

Re: Joining tables with GroupBy

@v-xida-msft you, sir, are a legend! Worked perfectly. Amazing. Thank you so much.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (7,658)