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
Vysakh
Regular Visitor

Display latest data based on other fields

Hi all,

 

Below is a sample data set:

 

PO#Invoice#DateQuantity
123q12301-02-202020
456q45602-02-202030
789q78903-04-20202
789a78905-04-20203
789z78906-04-20205

 

I want to display the latest data for each PO#, hence the result should be:

 

PO#Invoice#DateQuantity
123q12301-02-202020
456q45602-02-202030
789z78906-04-20205

 

Any suggestion on how I can achieve this via DAX?

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Vysakh 

 

You can create a measure like below 

Measure = 
VAR __maxDate = 
    CALCULATE(
        MAX( 'Table'[Date] ),
        ALL( 'Table' ),
        VALUES( 'Table'[PO#] )
    )
RETURN 
CALCULATE(
    INT( NOT ISEMPTY( 'Table' ) ),
    'Table'[Date] = __maxDate 
)

 

And use it as a visual filter like below

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Measure =
VAR __id = MAX ( 'Table'[PO #] )
VAR __date = CALCULATE ( MAX( 'Table'[Date] ), ALLSELECTED ( 'Table' ), 'Table'[PO #] = __id )
RETURN CALCULATE ( sum ( 'Table'[Quantity] ), VALUES ( 'Table'[PO # ), 'Table'[PO #] = __id, 'Table'[Date] = __date )

Mariusz
Community Champion
Community Champion

Hi @Vysakh 

 

You can create a measure like below 

Measure = 
VAR __maxDate = 
    CALCULATE(
        MAX( 'Table'[Date] ),
        ALL( 'Table' ),
        VALUES( 'Table'[PO#] )
    )
RETURN 
CALCULATE(
    INT( NOT ISEMPTY( 'Table' ) ),
    'Table'[Date] = __maxDate 
)

 

And use it as a visual filter like below

image.png

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

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.