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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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