cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tiksha
Helper II
Helper II

Group By To get Highest Date

Hello People, 

I'm trying to group the columns Brand Name and Inspection date to get the highest date by brand. But I'm getting the error. Could anyone please review the code. It will be really great.

Input:- 

Mercedes14/4/2000
Mercedes1/12/2006
Mercedes2/12/2020
BMW1/12/2018
BMW25/5/2018
BMW25/5/2019
Audi25/5/2018
Audi1/12/2019
Audi1/12/2020

 

Output:-

Mercedes2/12/2020
BMW25/5/2019
Audi1/12/2020

 

 

 

ClearCollect(myBrand,DropColumns(AddColumns(GroupBy(myBrandItems,"Vehicle_Brand","Date for Inspection"),"Brand Date",First(Sort(Brand_Details, Inspection_Date,Descending)).Inspection_Date)),"Date for Inspection")

 

 

 

Thanks 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Tiksha ,

GroupBy() needs a "grouped" column - try the below

ClearCollect(
   myBrand,
   AddColumns(
      GroupBy(
         Sort(
            myBrandItems,
            Inspection_Date,
            Descending
         ),			   
         "Vehicle_Brand",
         "Data"
      ),
      "Brand Date",
      First(Data).Inspection_Date
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @Tiksha ,

GroupBy() needs a "grouped" column - try the below

ClearCollect(
   myBrand,
   AddColumns(
      GroupBy(
         Sort(
            myBrandItems,
            Inspection_Date,
            Descending
         ),			   
         "Vehicle_Brand",
         "Data"
      ),
      "Brand Date",
      First(Data).Inspection_Date
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,724)