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
montibellin
Helper I
Helper I

Filter last date value for each item in a Table in DAX

Hello,

 

how can filter for each item the last value by date?

 

montibellin_1-1630759586404.png

 

thank you for you help

 

1 ACCEPTED SOLUTION

Dear VahidDM,

there's some problem with date duplicate.

I've resolved with this code:

Measure =
VAR maxd =
CALCULATE (
MAX ( Table[Time]),
ALLSELECTED ( Table ),
VALUES ( Table[Item])
)
RETURN
IF ( MAX ( Table[Time] ) = maxd, 1, BLANK () )

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi @montibellin 

 

Try to create a measure with this code and add that to the table with Item and Value:

 

Last Value =
VAR _Ldate =
    LASTDATE ( 'Table'[Date] )
RETURN
    IF (
        CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Item] ) ) = _Ldate,
        _Ldate,
        BLANK ()
    )

 

 

Output:

VahidDM_2-1630765306139.png

 

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

Appreciate your Kudos✌️!!

Dear VahidDM,

there's some problem with date duplicate.

I've resolved with this code:

Measure =
VAR maxd =
CALCULATE (
MAX ( Table[Time]),
ALLSELECTED ( Table ),
VALUES ( Table[Item])
)
RETURN
IF ( MAX ( Table[Time] ) = maxd, 1, BLANK () )
Greg_Deckler
Super User
Super User

@montibellin Use Lookup Min/Max: Lookup Min/Max - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg but I don't need to summarize the values of each items. the result table must contain the value related to the last date.

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.