Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PBI_Monkey
Helper I
Helper I

Show only last user that accessed the object last (Max)

Hi all,

 

I have a list like this which shows when a User Last acccessed an Object:

 

User_NameStart_TimeObject_Name
User11/01/2023 22:07Report1
User21/10/2023 22:07Report1
User35/09/2023 22:07Report2
User15/09/2023 22:07Report3
User37/10/2023 22:07Report3
User223/10/2023 22:07Report3
  

 

I want to show when the Object was accessed last and by which User:

 

Want to show only last user that accessed the object last
User_NameStart_TimeObject_Name
User21/10/2023 22:07Report1
User35/09/2023 22:07Report2
User223/10/2023 22:07Report3

 

Any ideas on how I can achieve this without using SQL? 

I have tried achieving this with 'Latest' in Power Bi but that doesn't give 1 last user by Object that it was accessed.

 

Thanks

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @PBI_Monkey 
You can create 2 measures :
1 for the latest start time by object :

last time of object =
var
grouped_table =
    SUMMARIZE('Table','Table'[Object_Name],"max start time",max('Table'[Start_Time]))
return
maxx(grouped_table,max([max start time]))
 
Ritaf1983_0-1698029563634.png

2. for last user based on the first measure :

last_user =
VAR vTable = VALUES('Table'[User_Name] )
VAR last_time_object = [last time of object]
VAR Keepmin = FILTER( vTable, max('Table'[Start_Time]) = [last time of object] )
VAR last_user = IF( [last time of object] >0, CONCATENATEX( Keepmin, [User_Name], ", "))
RETURN

last_user
 
 
Ritaf1983_1-1698029708658.png

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User_Name", type text}, {"Start_Time", type datetime}, {"Object_Name", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Object_Name"}, {{"All", each Table.Max(_,"Start_Time")}}),
    #"Expanded All" = Table.ExpandRecordColumn(#"Grouped Rows", "All", {"User_Name", "Start_Time"}, {"User_Name", "Start_Time"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded All",{{"Object_Name", type text}, {"User_Name", type text}, {"Start_Time", type datetime}})
in
    #"Changed Type1"

Hope this helps.

Ashish_Mathur_0-1698033251573.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"User_Name", type text}, {"Start_Time", type datetime}, {"Object_Name", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Object_Name"}, {{"All", each Table.Max(_,"Start_Time")}}),
    #"Expanded All" = Table.ExpandRecordColumn(#"Grouped Rows", "All", {"User_Name", "Start_Time"}, {"User_Name", "Start_Time"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded All",{{"Object_Name", type text}, {"User_Name", type text}, {"Start_Time", type datetime}})
in
    #"Changed Type1"

Hope this helps.

Ashish_Mathur_0-1698033251573.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ritaf1983
Super User
Super User

Hi @PBI_Monkey 
You can create 2 measures :
1 for the latest start time by object :

last time of object =
var
grouped_table =
    SUMMARIZE('Table','Table'[Object_Name],"max start time",max('Table'[Start_Time]))
return
maxx(grouped_table,max([max start time]))
 
Ritaf1983_0-1698029563634.png

2. for last user based on the first measure :

last_user =
VAR vTable = VALUES('Table'[User_Name] )
VAR last_time_object = [last time of object]
VAR Keepmin = FILTER( vTable, max('Table'[Start_Time]) = [last time of object] )
VAR last_user = IF( [last time of object] >0, CONCATENATEX( Keepmin, [User_Name], ", "))
RETURN

last_user
 
 
Ritaf1983_1-1698029708658.png

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
PBI_Monkey
Helper I
Helper I

Thanks for the quick reply @littlemojopuppy, but how can I achieve this.

Apologies, I'm new to Power Bi 😉

@PBI_Monkey What have you tried in the five minutes since I replied? 😉

littlemojopuppy
Community Champion
Community Champion

LASTNONBLANK() should work.  No such thing as LATEST() 😉

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.