cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors