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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors