Skip to main content

Notifications

Announcements

No record found.

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?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamically check difference between elements in a list

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans