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
NickProp28
Post Partisan
Post Partisan

How to add more conditions to the IF statement

Dear Community,

 

How can I add a condition to only show results for the MIN legs of each job number?

New column = IF(Checking[Departure]<= Checking[Arrival] , FALSE(),TRUE())

My expected outcome:

LegsJob NumberDepartureArrivalNew column
1S00110/3/20226/3/2022TRUE
2S0017/3/202210/3/2022 
3S00118/3/202215/3/2022 
4S00115/3/202217/3/2022 
1S0021/4/20228/4/2022FALSE
2S0029/4/202211/4/2022 

 

Thanks for your help!

 

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @NickProp28 ,

 

You could try below code:-

 

New Column = 
VAR _min_leg =
    CALCULATE (
        MIN ( 'Table'[Legs] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Job Number] = EARLIER ( 'Table'[Job Number] )
        )
    )
VAR _result2 =
    IF ('Table'[Departure] <= 'Table'[Arrival],"FALSE","TRUE")
RETURN
    IF( 'Table'[Legs] = _min_leg,_result2,BLANK())

 

Output:-

Samarth_18_0-1668765780856.png

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @NickProp28 ,

 

You could try below code:-

 

New Column = 
VAR _min_leg =
    CALCULATE (
        MIN ( 'Table'[Legs] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Job Number] = EARLIER ( 'Table'[Job Number] )
        )
    )
VAR _result2 =
    IF ('Table'[Departure] <= 'Table'[Arrival],"FALSE","TRUE")
RETURN
    IF( 'Table'[Legs] = _min_leg,_result2,BLANK())

 

Output:-

Samarth_18_0-1668765780856.png

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

amitchandak
Super User
Super User

@NickProp28 , Try like

 

if( [Legs] = minx(filter(Table, [Job Number] = earlier([Job Number]) ), [Legs]) ,
IF(Checking[Departure]<= Checking[Arrival] , FALSE(),TRUE()), blank())

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

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.