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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
insandur
Helper II
Helper II

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]
)


Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



View solution in original post

insandur
Helper II
Helper II

This worked, Thank you for quick response

View solution in original post

3 REPLIES 3
insandur
Helper II
Helper II

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]
)


Microsoft MVP



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.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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