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 / ForAll and multiple So...
Power Apps
Unanswered

ForAll and multiple Sort values

(0) ShareShare
ReportReport
Posted on by 121

I am using the following code to get the newest distinct value based on Unique GRS 

 

ForAll(
 GroupBy(
 LogDataALL,
 "GRS",
 "_items"
 ),
 First(
 Sort(
 _items,
 'Log Date',
 SortOrder.Descending
 )
 )
)

 

What i need to add is another Sort function that will show the oldest record 1st based on the unique values.

 

Any ideas welcome please

 

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

    Hi @Markswan20 ,

     

    Please try this:

     

    ForAll(
     Distinct(
     LogDataALL,
     GRS
     ) As C,
     Last(
     Sort(Filter(
     LogDataALL,GRS=C.Value),
     'Log Date',
     SortOrder.Descending
     )
     )
    )

     

     

     

    Best regards,

    Rimmon

  • Markswan20 Profile Picture
    121 on at

    Thanks for the response Rimmon, this gives the same results as my code.

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

    Sorry, I didn't notice that.

    I have just modified my formula, or you can replace First with Last in your formula.

  • Markswan20 Profile Picture
    121 on at

    That's ok, by replacing First to Last it give me the oldest unique value instead of the newest.

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

    Hi @Markswan20 ,

     

    Do you want newest and oldest at the same time?

    Please try this:

    Ungroup(ForAll(
     Distinct(
     LogDataALL,
     GRS
     ) As C,
     Table(Last(
     Sort(Filter(
     LogDataALL,GRS=C.Value),
     'Log Date',
     SortOrder.Descending
     )
     ),
     First(
     Sort(Filter(
     LogDataALL,GRS=C.Value),
     'Log Date',
     SortOrder.Descending
     )))
    ),"Value")

     

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

    Hi @Markswan20 ,

     

    How is the situation now?

     

  • Markswan20 Profile Picture
    121 on at

    Thanks for the suggestion, this seems to have now lost the Unique validation from the GRS field and now hides many of the fields that are powered by the drop down.

     

    I use this in my visible field 

    HubSelection_1.Selected.Value in ThisItem.ManagerLevel

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard