Skip to main content

Notifications

Announcements

No record found.

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
 
 
 
  • Andrew Baker Idahoan Profile Picture
    7 on at
    How to perform MAX date in data entity
    **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?
     
  • Verified answer
    Layan Jwei Profile Picture
    7,820 Super User 2025 Season 1 on at
    How to perform MAX date in data entity
    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
  • Alex C Profile Picture
    84 on at
    How to perform MAX date in data entity
    @Layan Jwei
    Do you have an example of what you mean? Not sure I understand...
     
    Thanks
  • Layan Jwei Profile Picture
    7,820 Super User 2025 Season 1 on at
    How to perform MAX date in data entity
    Hi,
     
    Did you check the aggregate property on the field in the entity where you can choose "Max" and see if it helps?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Zain Mehmood Profile Picture

Zain Mehmood 128 Moderator

#2
Siv Sagar Profile Picture

Siv Sagar 109 Super User 2025 Season 1

#3
Danny Bilodeau Profile Picture

Danny Bilodeau 50 Moderator

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans