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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / ODATA filter for recor...
Power Automate
Unanswered

ODATA filter for records where field not found in array?

(0) ShareShare
ReportReport
Posted on by 189
I have a CDS entity with the fields Person and LoginDate. The entity keeps a history of all logins, so there are multiple Emmas with different dates, and multiple Johns with different dates, and so on. I need a weekly email with a list of people, no duplicates of course, who haven't logged in in the last 6 months.
 
It sounds easy and straightforward, but it's starting to seem like Flow doesn't support this by itself and I would need to employ a workaround, like creating another entity.
 
Ideally I want to be able to use groupby and Max(Date) per group, but Max(Date) doesn't exist in Flow and I can't use groupby without aggregate. So my 2nd option Flow I'm trying to achieve is:
 
  1. Filter records for Date within the last 6 months
  2. From the filtered records, union Person into array "varUniqueArray1" with no duplicates (unique persons who have logged in in 6 mths)

  3. List records again, filter for Person not found in varUniqueArray1
  4. From the filtered records, union Person into array "varUniqueArray2" with no duplicates (unique persons who haven't logged in in 6 mths)
 
Unfortunately the flow fails at #3. Is the kind of filter I'm hoping to do even possible?
 
My third option is to tackle the task at the point of record creation (of the CDS entity). But first, I'll create a new entity with the fields Person and LatestLoginDate. Whenever the original entity (the history) adds a new record (record creation), I'll lookup the Person in my second entity, if it exists there I'll overwrite the LatestLoginDate, if it doesn't exist I'll add a new record. Then I'll use flow to filter that second entity for records with LatestLoginDate older than 6 months, and then send that email.
 
Can someone confirm please if Flow is unable to accommodate both my 1st option (use groupby and max(date)) and 2nd option (use process of elimination)?
 
Edited to add:
I simplified my scenario for ease of story telling. My Person field is actually a calculated field that concatenates 3 different fields in the entity because it takes 3 fields to make up a unique identifier. The LoginDate field is also not a login but a different date context.
Categories:
I have the same question (0)
  • MJain Profile Picture
    2,450 on at
    Re: ODATA filter for records where field not found in array?

    Hi @Lexicron ,

     

    User entity does provide last login date field , so are you referring to this entity ? If yes , may be you should use this field rather than pulling all records and filtering later on. 

     

    Thanks

  • Lexicon_ Profile Picture
    189 on at
    Re: ODATA filter for records where field not found in array?

    Hi @ManishJain,

     

    I simplified my scenario for ease of story telling. My Person field is actually a calculated field that concatenates 3 different fields in the entity because it takes 3 fields to make up a unique identifier. The 3 fields are not in the User entity. The LoginDate is also not a LoginDate but has a different date context.

  • v-alzhan-msft Profile Picture
    on at
    Re: ODATA filter for records where field not found in array?

    Hi @Lexicron ,

     

    Refer to link below and hope it could helps.

    https://powerusers.microsoft.com/t5/Building-Flows/Check-if-an-item-exists-in-a-SharePoint-list/td-p/199061

     

    You could filter the records with the person and the date, then check if an record exist with the length expression in the Condition.

     

    Best regards,

    Alice   

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Verified answer
    Lexicon_ Profile Picture
    189 on at
    Re: ODATA filter for records where field not found in array?

    I have employed a workaround that works:

     

    Let's call my original entity "CDSHistory".

     

    I created a new entity called "CDSLatestOnly" with fields UniqueID and LatestDate. UniqueID is a concatenation of Person and Site.

     

    At the point of record creation in CDSHistory (which is done in a Canvas app using patch), I also looked up the Person+Site string in CDSLatestOnly under UniqueID. If it exists, I'll update the LatestDate with Today(). If it doesn't exist, I'll add a record for it with LatestDate = Today().

     

    Then I created a Flow that looks that CDSLatestOnly and filters for LatestDate lt (utcnow() - 6 months).

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard