Creating measure selecting latest date and time

MrHest

New Member
Joined
May 22, 2019
Messages
1
Hi there,

Im looking for help to write the correct measure to pick the price based on the latest date and time.

A simplified version of my data set looks like this :

IDPriceTime
2115,221.05.2019 10:00
2115,921.05.2019 10:10
2115,521.05.2019 10:20
2114,720.05.2019 19:00
2114,920.05.2019 19:30

<tbody>
</tbody>


Im looking for the outcome where i write a measure, and it picks the latest observation, and in this case display the price 15,50 from the newest observation made 21.05.2019 at 10:20
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
There's nothing in the data that reflects the word "measure"
You "write a measure"
What is measure?
Is it ID?
Then why not call it ID in your description?
 
Upvote 0
Is this what you mean?

in D1 enter an ID
in D2
=MAX(IF(D1=A$2:A$6,C$2:C$6))
Array formula, use Ctrl-Shift-Enter
 
Upvote 0
Is this what you mean?

in D1 enter an ID
in D2
=MAX(IF(D1=A$2:A$6,C$2:C$6))
Array formula, use Ctrl-Shift-Enter

returns latest date
Then just use

=INDEX(B$2:B$6,MATCH(MAX(IF(D1=A$2:A$6,C$2:C$6)),C$2:C$6,0),1)
to get the price
(assuming there are not identical dates/times in column C)
 
Upvote 0
Hi,

To filter on the 'maximum' value of any column within a DAX measure, the LASTNONBLANK is a convenient way of doing this:

Code:
Price at latest time =
CALCULATE ( 
    AVERAGE ( YourTable[Price] ),
    LASTNONBLANK ( YourTable[Time], 0 )
)

You need to aggregate Price in some way, so AVERAGE is an arbitrary aggregation that is probably appropriate for Price.

Regards,
Owen
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,916
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top