Skip to main content

Notifications

Community site session details

Community site session details

Session Id : DRghkZtJLoJBf4Yh6z+oPC
Power Apps - Building Power Apps
Unanswered

Using GroupBy and Left functions in PowerApps

Like (0) ShareShare
ReportReport
Posted on 1 Apr 2024 19:20:05 by 38

I have a SharePoint List with the Title field populated with the following data format:

 

24-1000.01

24-1000.02

24-1001.01

24-1002.01

24-1002.02

24-1002.03

 

The first thing I am trying to do with this data is use the GroupBy and Left functions to look at the 7 leftmost characters, then display a list of unique values in a gallery. So, the results would be:

 

24-1000

24-1001

24-1002

 

 

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on 09 Apr 2024 at 21:10:53
    Re: Using GroupBy and Left functions in PowerApps

    @metalproswi - that is a completely different format than the one you asked for in your first post. You're going to need to create a Nested Gallery for that.

     

    https://www.youtube.com/watch?v=25_bdexevGk 

  • metalproswi Profile Picture
    38 on 09 Apr 2024 at 15:28:15
    Re: Using GroupBy and Left functions in PowerApps

    Sorry about that. I was trying several things. The formula is no longer erroring; however the data is not displaying correctly. 

     

    My data set is like this:

    24-1000.01

    24-1000.02

    24-1001.01

    24-1002.01

    24-1002.02

    24-1002.03

     

    And I would like to display it like this:

    24-1000

         24-1000.01

         24-1000.02

     

    24-1001

         24-1001.01

     

    24-1002

         24-1002.01

         24-1002.02

         24-1002.03

     

    This is the what the current output is displaying like:

    metalproswi_0-1712676458761.png

     

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on 09 Apr 2024 at 11:46:25
    Re: Using GroupBy and Left functions in PowerApps

    @metalproswi - please could you use the code I provided. At present you're trying to do something else (using the Distinct function is not part of my suggestion).

  • metalproswi Profile Picture
    38 on 09 Apr 2024 at 11:36:55
    Re: Using GroupBy and Left functions in PowerApps

    I am using an empty column in my SharePoint List, but I can't get past the generic 'invalid arguments' message. I will read up more on the AddColumns function.

     

    metalproswi_0-1712662446574.png

     

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on 08 Apr 2024 at 19:43:09
    Re: Using GroupBy and Left functions in PowerApps

    @metalproswi:

     

    "metalproswi_custom_column" is a random name I gave to the newly added column. You can use any name you want.

     

    DropColumns(
     GroupBy(
     AddColumns(
     '2024 MP Lot Records',
     "title_custom",
     Left(
     Title,
     7
     )
     ),
     "title_custom",
     "GroupedItems"
     ),
     "GroupedItems"
    )

     

    Further reading on the AddColumns function:

     

    https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-table-shaping

     

  • metalproswi Profile Picture
    38 on 08 Apr 2024 at 13:32:57
    Re: Using GroupBy and Left functions in PowerApps

    metalproswi_0-1712583121670.png

    I can't get past a logic error after entering the data source.

  • metalproswi Profile Picture
    38 on 02 Apr 2024 at 16:11:00
    Re: Using GroupBy and Left functions in PowerApps

    I tried the 'Distinct' and 'DropColumns' suggestions, however non worked in my gallery. I will try recreating my gallery from a basic app to rule out any other variables.

  • v-mengmli-msft Profile Picture
    on 01 Apr 2024 at 19:45:45
    Re: Using GroupBy and Left functions in PowerApps

    Hi @metalproswi ,

     

    Please try this.

    Distinct(Left(ListName.Title,7),Value)

     

    Best regards,

    Rimmon

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on 01 Apr 2024 at 19:45:09
    Re: Using GroupBy and Left functions in PowerApps

    @metalproswi - one example:

     

    DropColumns(
     GroupBy(
     AddColumns(
     'Your Table,
     "metalproswi_custom_column",
     Left(
     Title,
     7
     )
     ),
     "metalproswi_custom_column",
     "GroupedItems"
     ),
     "GroupedItems"
    )

     

    Please note the GroupBy function is not delegable.

  • BhaskarDhone Profile Picture
    810 Super User 2025 Season 1 on 01 Apr 2024 at 19:41:46
    Re: Using GroupBy and Left functions in PowerApps

    Try this on your gallery.

    Distinct(DataSource, Left(Title, 7))

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,089 Most Valuable Professional

Leaderboard