cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ryanb1
Level: Powered On

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
Highlighted
Community Support Team
Community Support Team

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
Highlighted
Community Support Team
Community Support Team

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

ryanb1
Level: Powered On

Re: Joining tables with GroupBy

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

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,146)