Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Creating Table with Distinct rows based off of a unique Part ID and displaying the Total Qty per Part ID

Like (0) ShareShare
ReportReport
Posted on 5 Aug 2020 16:40:40 by 115

I have a SQL Inventory that has multiple lines of the same Part but with different Purchase Order ID's related to the Part due to differing costs when the part was bought. I would like create a Data Table to show each part in a row and the total Qty of that PartID in a Data Table.

 

My data looks similar to this:

PartNamePartIDPOIDQty
57X60SC-CS320180100150
52X40CE-977F79100260
57X60SC-CS320180100350
64X180AO-649X102100412
52X40CE-977F79100560

 

I would Like the Data to look like this:

PartNamePartIDQty
57X60SC-CS320180100
52X40CE-977F79120
64X180AO-649X10212

 

I believe I have to use Distinct() and AddColumns() but Im just lost on how to put this together right now so any help would be appreciated!


Regards,

Keith

  • KMI-Keith Profile Picture
    115 on 05 Aug 2020 at 18:34:09
    Re: Creating Table with Distinct rows based off of a unique Part ID and displaying the Total Qty per Part ID

    @mdevaney Thank you!

    This was basically where I was at yesterday but I didnt drop the column. The other thing was I added a filtered (from 1,000 rows down to 125) collection and used that in your formula and it worked as at first it was only showing 1 row with a total of all the parts in the Qty label and nothing in the other 2. Again it could have been because of the size of the SQL DB even though I had set the row up to the 2000 max limit.

     

    IDK and right now I dont care as I can stop banging my head against the wall trying things!

     

    I appreciate the help!

    Keith

  • Verified answer
    mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 05 Aug 2020 at 17:05:03
    Re: Creating Table with Distinct rows based off of a unique Part ID and displaying the Total Qty per Part ID

    @KMI-Keith 
    If you put this code in the Items property of the gallery it should do the trick!

     

    RenameColumns(
     DropColumns(
     AddColumns(
     GroupBy(SQL_Table_Name,"PartName", "PartID" ,"GroupedItems"),
     "Total Qty", Sum(GroupedItems, Qty)
     ),
     "GroupedItems"
     ),
     "Total Qty",
     "Qty"
    );

     

     

    You are probably wondering: why are we dropping and renaming columns?  GROUPBY creates an extra column that is unneeded for the data table.

     


    The solution I gave is a slightly modified version of this GROUP BY and SUM example:

    https://matthewdevaney.com/powerapps-collections-cookbook/group-by-and-find-the-sum/


    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • eka24 Profile Picture
    20,921 on 05 Aug 2020 at 17:04:37
    Re: Creating Table with Distinct rows based off of a unique Part ID and displaying the Total Qty per Part ID

    On a Gallery items put;

    AddColumns(GroupBy(Datasource, "PartName","SumGrp"),"SumColumn", Sum(SumColumn, Qty))

     

    One of the label the Gallery should be;

    ThisItem.SumColumn

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started