web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Remove records from collection if condition

(1) ShareShare
ReportReport
Posted on by 9
Hi everyone,
 
I have a collection in my App. It has four columns - Date, Person, number and created. Acually it has more columns, but basiclly it looks like below:
 
Date                       Person                     created
01.01.2023             Michael                   01.02.2023
01.01.2023             Michael                   01.03.2023
01.01.2023             Michael                   01.04.2023
01.01.2023             Michael                   01.05.2023
01.01.2023             Michael                   01.06.2023
01.02.2002             Michael                   01.06.2023
01.01.2023             Anna                       01.02.2023
01.01.2023             Anna                       01.03.2023
01.02.2002             Anna                       01.06.2023
 
I'd like to count the rows of each person with the same date. If it's even, remove all records, if uneven, save only the the last created and remove the others. The result should look like this: 
 
Date                       Person                     created
01.01.2023             Michael                   01.06.2023
01.02.2002             Michael                   01.06.2023
01.02.2002             Anna                       01.06.2023
 
Does anyone has an idea?
Thank you.
I have the same question (0)
  • Verified answer
    Sami Ullah Profile Picture
    315 Moderator on at
    Hi, Please Try This.
     
    ClearCollect(
        GroupedCollection,
        AddColumns(
            GroupBy(
                MyCollection, // your collection name.
                Date,
                Person,
                GroupedRecords
            ),
            RecordCount,
            CountRows(GroupedRecords),
            created,
            Last(
                SortByColumns(
                    GroupedRecords,
                    "created",
                    SortOrder.Ascending
                )
            ).created
        )
    );
    ClearCollect(
        FinalCollection,
        ForAll(
            GroupedCollection,
            If(
                Mod(
                    RecordCount,
                    2
                ) = 1, // checking is odd count.
                ThisRecord
            )
        )
    );
     


    I have verify with your data.
  • PowerLiebhaberi Profile Picture
    9 on at
    Thank you so much :-)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans