web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to group by, then ...
Power Apps
Answered

How to group by, then take first line of a group

(0) ShareShare
ReportReport
Posted on by 3,347

I have a list of indexes in this data.  I want to group by WOxxx, then take the first (lowest index number) and only show that line in the result.  I feel like I'm close with this, but not yet.

 

ClearCollect(SN_Test_DF_Filtered,
 First(GroupBy(
 SortByColumns(
 Filter(SN_Test_DF_Idx, CompanySearch.Text in Company And 
 TypeSearch.Text in ValveType),
 "SN",Ascending),
 "WONum","SN2")))

 

SN         ValveType             Company                   WONum

martinav_0-1630423236054.png

 

So, I want this set reduced to these three lines.

 

35019.....

44372....

58589....

 

Categories:
I have the same question (0)
  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @martinav ,

    Can you try this approach:

     

    ClearCollect(SN_Test_DF_Filtered,
     DropColumns(
     AddColumns(
     GroupBy(
     Filter(SN_Test_DF_Idx, CompanySearch.Text in Company And TypeSearch.Text 
     in ValveType),
     "WONum","SN2"),
     "Result",
     First(Sort(SN2,SN,Ascending)).SN,
     "WONum","SN2")
    )

     

     The result should be a one column collection called by me "Result".

     

    Hope it helps !

  • Verified answer
    Ashwin7104 Profile Picture
    671 on at

    Hey @martinav ,

     

    Try below code and let know if it works for you

    ClearCollect( SN_Test_DF_Filtered, 
     ForAll( GroupBy(SortByColumns(Filter(SN_Test_DF_Idx, CompanySearch.Text in Company And 
     TypeSearch.Text in ValveType),"SN",Ascending),"WONum","SN2"), 
     { 
     SN: First(ThisRecord.SN2).SN, 
     WONum: ThisRecord.WONum 
     } 
     )
    )

     

  • martinav Profile Picture
    3,347 on at

    Seems I got some great help from two at once!!!  @Ashwin7104 , yours worked right out of the box.  Its also nice and tidy on how to get the rest of my columns in the result.

     

    @gabibalaban ,  I think what you provided would produce the same result.  However, something was broken, and I couldnt figure out what the issue was.  I'm not smart enough!!  So, I used @Ashwin7104 's solution this time.

     

    Thank you both for your help!!!

     

    Rod

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 414

#2
Valantis Profile Picture

Valantis 387

#3
timl Profile Picture

timl 344 Super User 2026 Season 1

Last 30 days Overall leaderboard