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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
newtopbidax
Frequent Visitor

DAX help on showing the names with amounts only that has recent date

Hi all,

I am struggling to show the names and amount, for only those records that has recent dates. I do have duplicate IDs with same name, as well as different names. the output section in the screenshot is how I want to see my data. I would appreciate your help.
I tried this but its not working:

IF(
    CALCULATE(
        MAX(table[Date]),
        ALLEXCEPT(table, table[ID])
    ) = MAX(table[Date]),
    SELECTEDVALUE(table[name],
    BLANK()

 

newtopbidax_0-1670263636383.png

 

1 ACCEPTED SOLUTION

@newtopbidax 
You are right. This is becuase the thr ID is not actually "in scope".
Please refer to attached sample file with the solution

1.png

Measure = 
SUMX ( 
    VALUES ( 'Table'[Name] ),
    CALCULATE ( 
        VAR CurrentAmount =
            MAX ( 'Table'[Amount] )
        VAR Result =
            MAXX (
                TOPN (
                    1,
                    FILTER ( ALL ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) ),
                    'Table'[Date]
                ),
                'Table'[Amount]
            )
        RETURN 
            IF ( CurrentAmount = Result, Result )
    )
)

 

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @newtopbidax 

Please try

=
MAXX (
TOPN (
1,
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
'Table'[Date]
),
'Table'[Amount]
)

Hi @tamerj1, thank you for a quick reply.

I tried your solution but I am still not getting the right output. I get the same amount for all names. If I filter for ID = 1, I'm getting this:

newtopbidax_0-1670265629847.png

 

How do I ignore the ones with older dates?

@newtopbidax 

=
VAR CurrentAmount =
MAX ( 'Table'[Value] )
VAR Result =
MAXX (
TOPN (
1,
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
'Table'[Date]
),
'Table'[Amount]
)
RETURN
IF ( CurrentAmount = Result, Result )

@tamerj1 
That's still not working, its taking me to the else condition and giving blank values for everything.

@newtopbidax 
You are right. This is becuase the thr ID is not actually "in scope".
Please refer to attached sample file with the solution

1.png

Measure = 
SUMX ( 
    VALUES ( 'Table'[Name] ),
    CALCULATE ( 
        VAR CurrentAmount =
            MAX ( 'Table'[Amount] )
        VAR Result =
            MAXX (
                TOPN (
                    1,
                    FILTER ( ALL ( 'Table' ), 'Table'[ID] = MAX ( 'Table'[ID] ) ),
                    'Table'[Date]
                ),
                'Table'[Amount]
            )
        RETURN 
            IF ( CurrentAmount = Result, Result )
    )
)

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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