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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors