cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Resolver I
Resolver I

GroupBy

Hi,  I have a collection and it is Grouped based on the EmployeeID.  And I'm summing up the pay for the week.

But within that Grouping, there is a comments section.  How do I get all the comments to combine into one field and be distinct?

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

@TB05 ,

To obtain that, there is small change in my previous formula. Put "," instead of char(10). I supposed that the delimatator is ",".

And on text property of the label use (you may need to adjust the formula):

With(
    {
        CommentsCollection: Split(
            AllCommentsForEmployeeID,
            ","
        )
    },
    Concat(
        ForAll(
            Distinct(
                CommentsCollection,
                Result
            ) As temp,
            CountIf(
                CommentsCollection,
                Result = temp.Result
            ) & " " & temp.Result
        ),
        Value & ", "
    )
)

 

View solution in original post

So, in other word, you don't need the number of appearence for each word? Check this out...

With(
{
CommentsCollection: Split( 
ThisItem.AllCommentsForEmployeeID,
","
)
},
Concat(
Distinct(
CommentsCollection,
Result
),
Result & ", "
)
)

 

View solution in original post

7 REPLIES 7
gabibalaban
Dual Super User
Dual Super User

@TB05 ,

Based on your description, I supose that you grouped by the datasource and sum pay for the week using something like:

 

AddColumns(
      GroupBy(YourDataSource,"EmployeeID","Result"),
      "PayForTheWeek",
      Sum(Result,PayForTheWeekColumn)
)

 

 Why don' t you add a new column to concat the comments column from each group by like this:

 

AddColumns(
      GroupBy(YourDataSource,"EmployeeID","Result"),
      "PayForTheWeek",
      Sum(Result,PayForTheWeekColumn),
      "AllCommentsForEmployeeID",
      Concat(Result,Comments & Char(10))
)

 

I used Char(10) to put comments each onnew line.

Hope it helps !

That worked great, one other question...so now in the text box, I have the following:

TB05_0-1634408504234.png

So, is there a way to count the DR and the Tier 1, Tier 2 and have them display like this:

4 DR, 2 Tier 1, 1 Tier 2, 1 Tier 3, 1 MSK or something like that??

 

Thanks for your quick response.

@TB05 ,

To obtain that, there is small change in my previous formula. Put "," instead of char(10). I supposed that the delimatator is ",".

And on text property of the label use (you may need to adjust the formula):

With(
    {
        CommentsCollection: Split(
            AllCommentsForEmployeeID,
            ","
        )
    },
    Concat(
        ForAll(
            Distinct(
                CommentsCollection,
                Result
            ) As temp,
            CountIf(
                CommentsCollection,
                Result = temp.Result
            ) & " " & temp.Result
        ),
        Value & ", "
    )
)

 

TB05
Resolver I
Resolver I

Thank you, that worked great!  Only had to change Split(ThisItem.AllComments......

TB05
Resolver I
Resolver I

Sorry to bother you, what if I just want to see in the text field, one word.  I have another text field that has 

multiple RPI, RPI, RPI and I only want to show one.  I tried to work your code to show one RPI but not successful.

So, in other word, you don't need the number of appearence for each word? Check this out...

With(
{
CommentsCollection: Split( 
ThisItem.AllCommentsForEmployeeID,
","
)
},
Concat(
Distinct(
CommentsCollection,
Result
),
Result & ", "
)
)

 

TB05
Resolver I
Resolver I

Thanks Again!  That worked great.  I have applied it to multiple text fields.

Have a great weekend!!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,952)