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

View all the Fabric Data Days sessions on demand. View schedule

Reply
rahul632soni
Helper I
Helper I

How to get Latest Location and Total Engine hours

Hey Community

SO i Have a table which Consist of 15 Coulmns , Out of Which Few columns are Vin (Vehicle Identification Number),gps_timestamp(timestamp at which data recorded),engine hours (Current Engine hours at that time stamp),lat(lattitude of Vehicle ),Lon(Longitude of Vehicle)

Sample data in below Table

vingps_timestampposition_latposition_lonENG_HOURS
HAJSR16HCMG6799056/12/2021 15:3345.85492706-119.593032812.9
HAJSR16HCMG6799056/12/2021 15:3445.85492706-119.593032812.9
HAJSR16HCMG6799056/12/2021 15:3545.85493469-119.593032812.9
HAJSR16HCMG6799056/12/2021 15:3645.85493469-119.593032812.9
HAJSR16HCMG6799056/12/2021 15:3745.85493469-119.593032812.9
HAJSR16HCMG6799056/12/2021 15:3845.85493851-119.593032813
HAJSR16HCMG6799056/12/2021 15:3945.85493851-119.593032813
HAJSR16HCMG6799056/12/2021 15:4045.85494232-119.593032813
HAJSR16HCMG6799056/12/2021 15:4145.85494614-119.593032813
HAJSR16HCMG6799056/12/2021 15:4245.85494614-119.593032813
HAJSR16HCMG6799056/13/2021 16:3145.85493088-119.593025213
HAJSR16HCMG6799056/13/2021 16:3245.85494614-119.593017613.1
HAJSR16HCMG6799056/13/2021 16:3345.85494995-119.593017613.1
HAJSR16HCMG6799056/13/2021 16:3445.85520172-119.592323313.1
HAJSR16HCMG6799056/13/2021 16:3545.85327148-119.591667213.1
HAJSR16HCMG6799056/13/2021 16:3645.85070801-119.591590913.1
HAJSR16HCMG6799056/13/2021 16:3745.84867859-119.593879713.1
HAJSR16HCMG6799056/13/2021 16:3845.84597397-119.593864413.2
HAJSR16HCMG6799056/13/2021 16:3945.84357071-119.59177413.2
HAJSR16HHNG68053510/21/2022 17:4840.89827347-98.384056091.3
HAJSR16HHNG68053510/21/2022 17:4940.89728546-98.383163451.3
HAJSR16HHNG68053510/21/2022 17:4940.8972702-98.383155821.3
HAJSR16HHNG68053510/25/2022 13:0740.89726257-98.383239751.4
HAJSR16HHNG68053510/25/2022 13:0740.89729309-98.383216861.4
HAJSR16HHNG68053510/25/2022 13:0840.89728546-98.383216861.4
HAJSR16HHNG68053510/25/2022 13:0940.89728165-98.383216861.4
HAJSR16HHNG68053510/25/2022 13:1040.89727783-98.383216861.4
HAJSR16HHNG68053510/25/2022 13:1140.89708328-98.382820131.4
HAJSR16HHNG68053510/25/2022 13:1240.89632034-98.382606511.5
HAJSR16HHNG68053510/25/2022 13:1340.89699554-98.382064821.5
HAJSR16HHNG68053510/25/2022 13:1440.89718246-98.379936221.5
HAJSR16HHNG68053510/25/2022 13:1540.89715958-98.380104061.5
HAJSR16HHNG68053510/25/2022 13:1640.89715576-98.381546021.5
HAJSR16HHNG68053510/25/2022 13:1740.89732742-98.383338931.5
HAJSR16HHNG68053510/25/2022 13:1840.89733505-98.383308411.6
HAJSR16HHNG68053510/25/2022 13:1940.8973999-98.385841371.6
HAJSR16HHNG68053510/25/2022 13:2040.89766693-98.387786871.6
HAJSR16HHNG68053510/25/2022 13:2140.89931488-98.388336181.6
HAJSR16HHNG68053510/25/2022 13:2340.90034485-98.389892581.6
HAJSR16HHNG68053510/25/2022 13:2440.90122986-98.389831541.6
HAJSR16HHNG68053510/25/2022 13:2540.900177-98.389968871.7
HAJSR16HHNG68053510/25/2022 13:2640.89981842-98.390632631.7

Now , I want to Get Latest Location of Vehicle and Also Total Engine Hours . Engine Hours need to calculate from a New Calculated Column which has difference of each row for each vin and then we can sum by Vin to Get Total Engine Hours.

Data is not sorted currently.

 

Thanks for Help

Regards

Rahul

 

2 REPLIES 2
Anonymous
Not applicable

Hi @rahul632soni ,

1. Please try to create measure with below dax formula:

latest_position_lat =
VAR _vin =
    SELECTEDVALUE ( 'Table'[vin] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [vin] = _vin )
VAR _max =
    MAXX ( tmp, [gps_timestamp] )
VAR _val =
    CALCULATE ( MAX ( [position_lat] ), FILTER ( tmp, [gps_timestamp] = _max ) )
RETURN
    _val
latest_position_lon =
VAR _vin =
    SELECTEDVALUE ( 'Table'[vin] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [vin] = _vin )
VAR _max =
    MAXX ( tmp, [gps_timestamp] )
VAR _val =
    CALCULATE ( MAX ( [position_lon] ), FILTER ( tmp, [gps_timestamp] = _max ) )
RETURN
    _val
total engin hours =
VAR _vin =
    SELECTEDVALUE ( 'Table'[vin] )
VAR tmp =
    FILTER ( ALL ( 'Table' ), [vin] = _vin )
RETURN
    SUMX ( tmp, [ENG_HOURS] )

2. add a table visual with filed and measure

vbinbinyumsft_0-1682576040422.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous 

Hello Thakns For Solution ,

However now thw things is, it has become a measure to calculate last Lat ans Lon so how would i use this to greate a map , What i wanted is to show the latest location of each machines .

Currently when i ma trying to plot map its not happening .

Thanks. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors