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...
Unanswered

Dynamically check difference between elements in a list

(1) ShareShare
ReportReport
Posted on by 5

I have a list of containing a set of number in ascending order. I have another set of numbers containing a few elements. I need to check the difference between elements in a list such that are present in a set and of the difference is 5 or more. I need to delete all the numbers higher than it. Example:

list contains {1,5,7,8,12,17,18}

set= {7,12,21}

I run a loop in a list pointing two elements. In the first 1 and 5. Since both of them are not in the set no need to calculate the difference.

We continue the same process till 7 and 8. Here, I need to check the difference between 7,8 but since 8 is not in the set, I need to do increments such that the difference between 12 and 7 is calculated. If the difference is 5 or more I need to delete all elements from the list which are higher than the number from set. i.e 7

In this case elements deleted from list are {8,12,17,18}. Only numbers below the number from the set are deleted with a condition that at least two numbers from the set are in the list and their gap is at least 5.

Here is the sample code I have written so far

for (int i=1;i<list.size();i++){

if(set.contains(list[i]) && set.contains(list[i+1]))

This checks only successive values and doesn't move ahead. How to make this dynamic?

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi ImranKhanNiazi,

    Could you tell me what app you are using in D365?

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
Martin Dráb Profile Picture

Martin Dráb 46 Most Valuable Professional

#2
Pallavi Phade Profile Picture

Pallavi Phade 33

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 28 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans