Forum Discussion

abbas_uddin's avatar
abbas_uddin
Helper I
5 years ago
Solved

Max Datetime by User with Coordinates

Dear Experts,

 

 I have a table in which User-ID, Recorded Datetime and coordinates are showing. Now i want to show only the max of datetime in the Maps visuals with coordinates. the data below is like this:

Consultant IDDatetimeStart Time LatitudeStart Time Longitude
A-116/8/2021 10:5925.233984355.3203666
A-116/8/2021 13:0825.233955555.3203741
A-116/8/2021 13:3425.233968955.3203736
A-116/9/2021 7:3525.234111455.3190147
A-116/9/2021 10:2825.233945255.3203874
B-206/8/2021 10:1725.3086978255.40167385
B-206/8/2021 14:0725.30856355.40197406
B-206/8/2021 14:2025.3085206255.40203467
B-206/8/2021 15:0225.3085571455.40198429
B-206/8/2021 17:2825.3085359155.40198806
B-206/8/2021 17:2825.3085575855.40196614
C-436/9/2021 9:2925.3344946355.38996968
C-436/9/2021 10:1725.333837555.38976669
A-2206/7/2021 19:4125.2001087755.275296
A-2206/8/2021 10:5425.20007255.2753205

 

The result which i expect is UserID, Max of time, and coordinate as follows:

 

USER IDDate TimeLatitudeLongitude
A-116/9/2021 10:2825.233945255.3203874
B-206/8/2021 17:2825.3085575855.40196614
C-436/9/2021 10:1725.333837555.38976669
A-2206/8/2021 10:5425.20007255.2753205

 

how to achieve this. i Tried creating new table with Summarize and calculate max but doesnt seem to work for me or i am not doing it right,

 

kindly help

 

regards,

Abbas

  • Hi, abbas_uddin 

    Please try the below for creating a new table.

     

    New Table =
    SUMMARIZECOLUMNS (
    'Table'[Consultant ID],
    'Table'[Datetime],
    'Table'[Latitude],
    'Table'[Longitude],
    FILTER (
    'Table',
    'Table'[Datetime]
    = CALCULATE (
    MAX ( 'Table'[Datetime] ),
    ALLEXCEPT ( 'Table', 'Table'[Consultant ID] )
    )
    )
    )
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

2 Replies

  • abbas_uddin , Try to add a measure like the first one and try

     

    cnt =
    VAR __id = MAX ('Table'[USER ID ] )
    VAR __date = CALCULATE ( MAX('Table'[Date Time] ), ALLSELECTED ('Table' ), 'Table'[USER ID] = __id )
    CALCULATE ( count ('Table'[USER ID] ), VALUES ('Table'[USER ID] ),'Table'[USER ID] = __id,'Table'[Date Time] = __date )

     

    if needed have measure for long/lat

    Longitude =
    VAR __id = MAX ('Table'[USER ID ] )
    VAR __date = CALCULATE ( MAX('Table'[Date Time] ), ALLSELECTED ('Table' ), 'Table'[USER ID] = __id )
    CALCULATE ( max ('Table'[Longitude] ), VALUES ('Table'[USER ID] ),'Table'[USER ID] = __id,'Table'[Date Time] = __date )

    Latitude =
    VAR __id = MAX ('Table'[USER ID ] )
    VAR __date = CALCULATE ( MAX('Table'[Date Time] ), ALLSELECTED ('Table' ), 'Table'[USER ID] = __id )
    CALCULATE ( max ('Table'[Longitude] ), VALUES ('Table'[USER ID] ),'Table'[USER ID] = __id,'Table'[Date Time] = __date )

  • Hi, abbas_uddin 

    Please try the below for creating a new table.

     

    New Table =
    SUMMARIZECOLUMNS (
    'Table'[Consultant ID],
    'Table'[Datetime],
    'Table'[Latitude],
    'Table'[Longitude],
    FILTER (
    'Table',
    'Table'[Datetime]
    = CALCULATE (
    MAX ( 'Table'[Datetime] ),
    ALLEXCEPT ( 'Table', 'Table'[Consultant ID] )
    )
    )
    )
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM