Return value based on most recent date

Hi All,

As a beginner to Power BI I probably have a relatively easy question :sweat_smile: :

I have a fact table that contains the price history of a certain asset (column named close):
afbeelding

Now I created a what if parameter in which the user can input the amount of stocks he owns. As a small detail I would like to create a card which shows the current total $ value of his holdings.

In other words: Todays value of the asset * the amount of stocks he owns.

I tried to create a formula with the LASTDATE function, but until now I havenā€™t succeeded.

It would be great if someone is willing to help me out.

Thank you,

Folkert

Hello Folkert,

Can you provide a pbix sample of the scenario?

Thanks, so much!

PBIX example.pbix (155.3 KB)

Yes of course, please find attached.
Just to be clear: Todays value = the ā€˜closedā€™-column price of the most recent date in the table.

@Folkert,

Hereā€™s a solution I worked up based on some sample date I had from another forum response. Iā€™m sure there is a more efficient way to do this, but as is often said on this forum ā€œif it works, it ainā€™t dumbā€ā€¦

Most Recent Price = 

VAR PriceDate =
CALCULATE(
    MAX( 'HRC Data'[Date] ),
    'HRC Data'[Price] <> BLANK()
)

VAR LatestPrice =
CALCULATE(
    SELECTEDVALUE( 'HRC Data'[Price] ),
    'HRC Data'[Date] = PriceDate
)

RETURN
LatestPrice 

image

Hope this is helpful. Solution file attached.

2 Likes

@BrianJ

Awesome, it worked, Cheers :smiley:

To the contributors of this post, thank you for all your inputs on this topic we are now tagging it as Solved. To help us learn more about your experience in the forum, please take a moment to answer this short forum survey. We appreciate all your help and suggestions. Thanks!