cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
insandur
Frequent Visitor

IF condition on multiple column condition based on latest date

when date is maximum and status is closed return "close" for the shipment for all dates and if max date has "Open" as status return "Open" for all dates for that shipments.
eg:

ShipmentsDateStatusNew Status
A7-OctOpenClose
A8-OctOPenClose
A9-OctCloseClose
B7-OctOpenOpen
C7-OctOpenClose
A6-OctOpenOpen
B8-OctOpenOpen
B9-OctOpenOpen
C8-OctCloseClose

 

3 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @insandur 

please try

New Status =
VAR CurrentShipmentTable =
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Shipments] ) )
VAR LastRecord =
    TOPN ( 1, CurrentShipmentTable, 'Table'[Date] )
RETURN
    MAXX ( LastRecord, 'Table'[Status] )

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1665374987137.png

 

 

New Status CC =
MAXX (
    FILTER (
        Data,
        Data[Shipments] = EARLIER ( Data[Shipments] )
            && Data[Date]
                = MAXX (
                    GROUPBY (
                        FILTER ( Data, Data[Shipments] = EARLIER ( Data[Shipments] ) ),
                        Data[Shipments],
                        "@maxdate", MAXX ( CURRENTGROUP (), Data[Date] )
                    ),
                    [@maxdate]
                )
    ),
    Data[Status]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

insandur
Frequent Visitor

This worked, Thank you for quick response

View solution in original post

3 REPLIES 3
insandur
Frequent Visitor

This worked, Thank you for quick response

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1665374987137.png

 

 

New Status CC =
MAXX (
    FILTER (
        Data,
        Data[Shipments] = EARLIER ( Data[Shipments] )
            && Data[Date]
                = MAXX (
                    GROUPBY (
                        FILTER ( Data, Data[Shipments] = EARLIER ( Data[Shipments] ) ),
                        Data[Shipments],
                        "@maxdate", MAXX ( CURRENTGROUP (), Data[Date] )
                    ),
                    [@maxdate]
                )
    ),
    Data[Status]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


tamerj1
Super User
Super User

Hi @insandur 

please try

New Status =
VAR CurrentShipmentTable =
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Shipments] ) )
VAR LastRecord =
    TOPN ( 1, CurrentShipmentTable, 'Table'[Date] )
RETURN
    MAXX ( LastRecord, 'Table'[Status] )

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!