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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
VitorXavierCell
Regular Visitor

How to get a value of the last date?

Hello, 

 

I have a database that has the following colunms: Product, Date and value. I need to get the value of the last date per product, to put in a card. How can I do this?

 

Best regards!

2 ACCEPTED SOLUTIONS
v-yinliw-msft
Community Support
Community Support

Hi @VitorXavierCell ,

 

You can try the following methods.

 

Here is my test table:

vyinliwmsft_0-1663225184740.png

 

 

Measure:

Max date =

CALCULATE (

    MAX ( 'Product'[Date] ),

    FILTER ( 'Product', [Product] = SELECTEDVALUE ( 'Product'[Product] ) )

)
Max date value =

CALCULATE (

    MAX ( 'Product'[Value] ),

    FILTER (

        'Product',

        [Date] = [Max date]

            && [Product] = SELECTEDVALUE ( 'Product'[Product] )

    )

)

 

The result is:

vyinliwmsft_1-1663225184750.png

 

 

Is this the result you expect?

 

Best Regards,

Community Support Team _Yinliw

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

5 REPLIES 5
v-yinliw-msft
Community Support
Community Support

Hi @VitorXavierCell ,

 

You can try the following methods.

 

Here is my test table:

vyinliwmsft_0-1663225184740.png

 

 

Measure:

Max date =

CALCULATE (

    MAX ( 'Product'[Date] ),

    FILTER ( 'Product', [Product] = SELECTEDVALUE ( 'Product'[Product] ) )

)
Max date value =

CALCULATE (

    MAX ( 'Product'[Value] ),

    FILTER (

        'Product',

        [Date] = [Max date]

            && [Product] = SELECTEDVALUE ( 'Product'[Product] )

    )

)

 

The result is:

vyinliwmsft_1-1663225184750.png

 

 

Is this the result you expect?

 

Best Regards,

Community Support Team _Yinliw

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

Why is this accepted as solution when SELECTEDVALUE would only work when there's exactly one value selected for a given dimension? There could easily me more than one or none Product(s) selected at all...

VitorXavierCell
Regular Visitor

Thank you @amitchandak for the answer. I'll try those articles.

 

amitchandak
Super User
Super User

Why can't we just use LASTNONBLANK/LASTNONBLANKVALUE here?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.