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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors