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 :
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,280 Super User 2026 Season 1 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,280 Super User 2026 Season 1 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

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 88 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

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

#3
Sagar Suman Profile Picture

Sagar Suman 64 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans