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
Euro0681
Helper II
Helper II

Return Max Date

Euro0681_3-1670602238115.png

The Table on the left is all of my data, meaning if i Drag and drop all Columns into a Table in Power BI I will see the Table on the left.
The problem is i'm wanting to see the Table Displayed on the right I can't simply use a filter since I want to see both 'Delivered' and 'In Progress' Without duplicates and for the duplicates just show me the customer with MAX Date between the 2.
I've tried implementing a logic to return max date if value repeats?....

Calculated Column 1 = Concatenate( 'Table'[ID], Concatenate( " ",'Table'[Name] ) ) <---- To give me a Unique Value
Calculated Column 2 = If ( Count ('Table'[Calculate Column 1] > 1, Max ( 'Table'[Order Date] ), 'Table'[Order Date] ) <-- Problem

I then wanted to use Calculated Column 2 instead of [Order Date] so I could display the table on the right (since all values for repeating customers would be the same removing the duplicates and only showing the most recent values), But for 
Calculated Column 2 It's returning me the MAX for the entire order date column which is '6/13/2023' 
so if anybody has any suggestions to return the MAX date for duplicates but the MAX date should only be the MAX between the duplicates (Example Below)? 

Euro0681_0-1670603387137.png

 

 

 

 

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @Euro0681 ,

 

Create a new column:

Max_date = MAXX(FILTER('Table','Table'[ID] = EARLIER('Table'[ID])),[Order Date])

 

Your expected output2:

vyadongfmsft_2-1670828954892.png

 

Create a measure:

Measure = 
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) )
    )
VAR max_date =
    MAXX (
        FILTER ( 'Table', 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        [Order Date]
    )
VAR _status =
    IF (
        _count > 1
            && MAX ( 'Table'[Order Date] ) = max_date,
        MAX ( 'Table'[Delivered/In progess] ),
        MAX ( 'Table'[Delivered/In progess] )
    )
RETURN
    IF ( ISINSCOPE ( 'Table'[ID] ), _status, BLANK () )

 

Your expected output1:

vyadongfmsft_3-1670829012730.png

 

Best regards,

Yadong Fang

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

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

Hi @Euro0681 ,

 

Create a new column:

Max_date = MAXX(FILTER('Table','Table'[ID] = EARLIER('Table'[ID])),[Order Date])

 

Your expected output2:

vyadongfmsft_2-1670828954892.png

 

Create a measure:

Measure = 
VAR _count =
    CALCULATE (
        COUNT ( 'Table'[ID] ),
        FILTER ( 'Table', 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) )
    )
VAR max_date =
    MAXX (
        FILTER ( 'Table', 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        [Order Date]
    )
VAR _status =
    IF (
        _count > 1
            && MAX ( 'Table'[Order Date] ) = max_date,
        MAX ( 'Table'[Delivered/In progess] ),
        MAX ( 'Table'[Delivered/In progess] )
    )
RETURN
    IF ( ISINSCOPE ( 'Table'[ID] ), _status, BLANK () )

 

Your expected output1:

vyadongfmsft_3-1670829012730.png

 

Best regards,

Yadong Fang

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

amitchandak
Super User
Super User

@Euro0681 ,

 

Try a new column like

 

maxx(filter(Table, [ID] = earlier([ID]) ), [Order 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.