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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Active Discussion

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?

  • 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
Subra Profile Picture

Subra 120

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 92 Super User 2026 Season 1

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 83 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans