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 / Filtering for the late...
Power Apps
Answered

Filtering for the latest version

(0) ShareShare
ReportReport
Posted on by 7

I have a table named docList that holds the DocNumber, DocNumber, and DocTitle.

IDDocNumberDocVersionDocTitle
1ABC-0012300Quick Brown Fox
2ABC-0045600Lorem Ipsum
3ABC-0045601Lorem Ipsum
4ABC-0078900Foobar
5ABC-0045602Lorem Ipsum

 

How I can apply Filter / Select to have a new table of the documents with the latest version? Namely, I'd like to get:

IDDocNumberDocVersionDocTitle
1ABC-0012300Quick Brown Fox
4ABC-0078900Foobar
5ABC-0045602Lorem Ipsum

 

I tried to use Distinct(), but it returns only DocNumber column.

 

Thanks in advance,

simasima

Categories:
I have the same question (0)
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @simasima ,

     

    Yes, the Distinct Function only return the result of the distinct column.

    Please try this workaround:

    ClearCollect(GroupedCol,GroupBy(DocList,"DocNumber","Grouped")); Clear(NewCol);
    ForAll(GroupedCol,Collect(NewCol,{DocNumber:DocNumber,ID:Last(Grouped).ID,DocVersion:Last(Grouped).DocVersion,DocTitle:Last(Grouped).DocTitle}))

     Hope this helps.

    Sik

  • CU-18081211-6 Profile Picture
    9,270 Moderator on at

    As I can see to a document number is corresponding a document title.

    I guess the simpliest method is this.

    Try to use:

    ClearCollect(YourNewCollection,

         AddColumns(

                    GroupBy(

                             YourCollection,"DocNumber","DocTitle","Result"

                     ),

                    "DocVersion",Max(Result,Version),

                    "ID",Result.ID

         )

    )

     

    Hope it helps !

  • simasima Profile Picture
    7 on at

    @gabibalaban,

    Apology for my bad example. DocTitle is not always same for the same DocNumber.

    I needed SortByColumns() and First() not to have [object Object] in the output. The code below works for me.

    ClearCollect(
     newCollection,
     AddColumns(
     GroupBy(
     SortByColumns(docLedger, "DocVer", Descending, "DocNumber", Ascending),
     "DocNumber", "Result"
     ),
     "DocVersion", First(Result.DocVer).DocVer, 
     "ID", First(Result.ID).ID,
     "Title", First(Result.Title).Title
     )
    )

     

    Thanks for the hint! 

  • simasima Profile Picture
    7 on at

    @v-siky-msft,

    Thank you. Your code works just I expected!

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @simasima ,

     

    My pleasure.

    Please mark my post as the answer to help other members find it readily.

    Sik

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard