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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

How to perform MAX date in data entity

(1) ShareShare
ReportReport
Posted on by 84
Hello,
 
I am attempting to create a data entity with the SysUserLog table to export the latest login date for a user (createdDateTime field). I am unsure how to perform the MAX date with a data entity to represent the following SQL query:
select UserId, Max(createdDateTime) AS 'LastLogin'
from SYSUSERLOG
group by UserId
 
Here is how I made the structure of the entity:
 
 
 
Is there a range I can apply for the MAX(createdDateTime) or should I go via a SysComputedColumn?
 
Thanks
 
 
 
I have the same question (0)
  • Layan Jwei Profile Picture
    8,133 Super User 2025 Season 2 on at
    Hi,
     
    Did you check the aggregate property on the field in the entity where you can choose "Max" and see if it helps?
  • Alex C Profile Picture
    84 on at
    @Layan Jwei
    Do you have an example of what you mean? Not sure I understand...
     
    Thanks
  • Verified answer
    Layan Jwei Profile Picture
    8,133 Super User 2025 Season 2 on at
    Hi Alex,

    Create a view with SysUserLog table. Add the field UserId and CreatedDateTime.
    Put userId in the groupBy node -- just as u did in the entity
    go to the createdDateTime field and change the aggregation property to Max.

    Now go to your entity and add this view as a datasource instead of the table.


    If you go to SQL, this view will give you this query:
    SELECT        MAX(CREATEDDATETIME) AS CREATEDDATETIME1, USERID, PARTITION, 1010 AS RECID
    FROM            dbo.SYSUSERLOG AS T1
    GROUP BY USERID, PARTITION

    Which is what you exactly want :)


    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Andrew Baker Idahoan Profile Picture
    7 on at
    **EDIT**
    Solved: I had to create a data view with the aggregation and then use that view in the entity instead of sysuserlog table itself. 

    **Original:
    I'm trying to do the exact same thing, (SysUserLog and all), but Aggregation property is not available.
     
    What am I missing?
     

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

News and Announcements

Season of Giving Solutions is Here!

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 221 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Sumit Singh Profile Picture

Sumit Singh 46

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans