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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get values based on maximum timestamp

Hi everyone,

 

I have a direct query model with machine sensor data. Basically, there are machines (about 100) with data like incoming and outgoing bar values updated every 30 seconds. A typical table looks like this:

MachineNumberLocalTagTimeStamp_ESTIncomingBarOutgoingBar
101/21/2022 6:0079.9494477.60694885
111/21/2022 6:0179.9909744377.65860748
101/21/2022 6:0280.283195577.54640198
111/21/2022 6:0380.1060028177.76474762

 

I want to idenity the latest timestamp for each machine along with it's associated incoming and outgoing bar values. So, the output should look like this since 10's latest time stamp is 6:02 and 11's is 6:03 and the associated bar values: 

101/21/2022 6:0280.283195577.54640198
111/21/2022 6:0380.1060028177.76474762

 

Since it's direct query, I can't use the all rows expansion method that I've seen other people use. Is there a way to do this using Summarize, for example?

 

Thank you so much in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to create a measure , add this measure into visual level filter in your visual and set it to show items when value =1.

Then your visual will only show the data in latest timestamp for each machine number.

Measure Filter = 
VAR _LatestTimeStamp_EachMachine = MAXX(FILTER(ALL('Table'),'Table'[MachineNumberLocal] = MAX('Table'[MachineNumberLocal])),'Table'[TagTimeStamp_EST])
RETURN
IF(MAX('Table'[TagTimeStamp_EST]) = _LatestTimeStamp_EachMachine,1,0)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@amitchandak 

 

I tried it and the measures behave a bit weirdly when used together. 

 

I brought in Machine Number, Incoming Bar and Outgoing Bar to the same table and it calculates the first measure just fine, but the second one does not show all values. For example, when icoming bar is added to the visual first, outgoing bar does not have all values. When outgoing bar is added to the table visual first (as in image below), incoming bar does not have all the values. 

Any idea why?

 

Screenshot (42).png

Anonymous
Not applicable

Hi @Anonymous ,

 

I suggest you to create a measure , add this measure into visual level filter in your visual and set it to show items when value =1.

Then your visual will only show the data in latest timestamp for each machine number.

Measure Filter = 
VAR _LatestTimeStamp_EachMachine = MAXX(FILTER(ALL('Table'),'Table'[MachineNumberLocal] = MAX('Table'[MachineNumberLocal])),'Table'[TagTimeStamp_EST])
RETURN
IF(MAX('Table'[TagTimeStamp_EST]) = _LatestTimeStamp_EachMachine,1,0)

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@Anonymous , Create two meausre like

 

IncomingBar Measure =
VAR __id = MAX ('Table'[MachineNumberLocal] )
VAR __date = CALCULATE ( MAX('Table'[TagTimeStamp_EST] ), ALLSELECTED ('Table' ), 'Table'[MachineNumberLocal] = __id )
CALCULATE ( MAX ('Table'[IncomingBar] ), VALUES ('Table'[MachineNumberLocal] ),'Table'[MachineNumberLocal] = __id,'Table'[TagTimeStamp_EST] = __date )

 


OutgoingBar Measure =
VAR __id = MAX ('Table'[MachineNumberLocal] )
VAR __date = CALCULATE ( MAX('Table'[TagTimeStamp_EST] ), ALLSELECTED ('Table' ), 'Table'[MachineNumberLocal] = __id )
CALCULATE ( MAX ('Table'[OutgoingBar] ), VALUES ('Table'[MachineNumberLocal] ),'Table'[MachineNumberLocal] = __id,'Table'[TagTimeStamp_EST] = __date )

 

 

if needed use max of TagTimeStamp_EST in visual

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors