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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NickProp28
Post Partisan
Post Partisan

IF else measure return 1 ,0 and blank

Dear community,

 

Any hints would be appreciated, I am trying my best to create this measure.

This is a condition that I'd like to convert into a measure.

Condition:

i.) When there is no flight time for direction 'APAC' AND the first character in the code is 'V', will return '0', otherwise '1'.But other than code start with 'V', with or without date, will return blank.

 

ii.) When there is no flight time for direction 'AMER', will return '0'

 

iii.) Direction 'EMEA' , with or without time flight, will return blank

 

Expected result:

NickProp28_0-1663820820782.png

 

Attached with pbix: https://drive.google.com/file/d/1PEkk4PX37H4w8_1c6Dcl_TpEUa8IpEmW/view?usp=sharing

Appreciate any helps provided ! Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @NickProp28 ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR shouzi =
    LEFT ( MAX ( FlightTable[Code] ), 1 )
RETURN
    IF (
        MAX ( FlightTable[Direction] ) = "APAC"
            && MAX ( FlightTable[Flight Time] ) = BLANK ()
            && shouzi = "V",
        0,
        IF (
            MAX ( FlightTable[Direction] ) = "APAC"
                && MAX ( FlightTable[Flight Time] ) <> BLANK ()
                && shouzi = "V",
            1,
            IF (
                MAX ( FlightTable[Direction] ) = "AMER"
                    && MAX ( FlightTable[Flight Time] ) <> BLANK (),
                1,
                IF (
                    MAX ( FlightTable[Direction] ) = "AMER"
                        && MAX ( FlightTable[Flight Time] ) = BLANK (),
                    0,
                    IF ( MAX ( FlightTable[Direction] ) = "EMEA", BLANK () )
                )
            )
        )
    )

Or a column.

Column =
VAR shouzi =
    LEFT ( ( FlightTable[Code] ), 1 )
RETURN
    IF (
        ( FlightTable[Direction] ) = "APAC"
            && ( FlightTable[Flight Time] ) = BLANK ()
            && shouzi = "V",
        0,
        IF (
            ( FlightTable[Direction] ) = "APAC"
                && ( FlightTable[Flight Time] ) <> BLANK ()
                && shouzi = "V",
            1,
            IF (
                ( FlightTable[Direction] ) = "AMER"
                    && ( FlightTable[Flight Time] ) <> BLANK (),
                1,
                IF (
                    ( FlightTable[Direction] ) = "AMER"
                        && ( FlightTable[Flight Time] ) = BLANK (),
                    0,
                    IF ( ( FlightTable[Direction] ) = "EMEA", BLANK () )
                )
            )
        )
    )

 

vpollymsft_0-1663915789153.png

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @NickProp28 ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
VAR shouzi =
    LEFT ( MAX ( FlightTable[Code] ), 1 )
RETURN
    IF (
        MAX ( FlightTable[Direction] ) = "APAC"
            && MAX ( FlightTable[Flight Time] ) = BLANK ()
            && shouzi = "V",
        0,
        IF (
            MAX ( FlightTable[Direction] ) = "APAC"
                && MAX ( FlightTable[Flight Time] ) <> BLANK ()
                && shouzi = "V",
            1,
            IF (
                MAX ( FlightTable[Direction] ) = "AMER"
                    && MAX ( FlightTable[Flight Time] ) <> BLANK (),
                1,
                IF (
                    MAX ( FlightTable[Direction] ) = "AMER"
                        && MAX ( FlightTable[Flight Time] ) = BLANK (),
                    0,
                    IF ( MAX ( FlightTable[Direction] ) = "EMEA", BLANK () )
                )
            )
        )
    )

Or a column.

Column =
VAR shouzi =
    LEFT ( ( FlightTable[Code] ), 1 )
RETURN
    IF (
        ( FlightTable[Direction] ) = "APAC"
            && ( FlightTable[Flight Time] ) = BLANK ()
            && shouzi = "V",
        0,
        IF (
            ( FlightTable[Direction] ) = "APAC"
                && ( FlightTable[Flight Time] ) <> BLANK ()
                && shouzi = "V",
            1,
            IF (
                ( FlightTable[Direction] ) = "AMER"
                    && ( FlightTable[Flight Time] ) <> BLANK (),
                1,
                IF (
                    ( FlightTable[Direction] ) = "AMER"
                        && ( FlightTable[Flight Time] ) = BLANK (),
                    0,
                    IF ( ( FlightTable[Direction] ) = "EMEA", BLANK () )
                )
            )
        )
    )

 

vpollymsft_0-1663915789153.png

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Chew_WenJie
Resolver III
Resolver III

Hello, you can use below measure to get the expected result table.

 

Measure = 
var direction = SELECTEDVALUE(FlightTable[Direction])
var code = LEFT(SELECTEDVALUE(FlightTable[Code]),1)
var flightTime = NOT(ISBLANK(SELECTEDVALUE(FlightTable[Flight Time]))) 

return
IF(direction="APAC"&&code="V"&&flightTime=FALSE(),0,
IF(direction="APAC"&&code="V"&&flightTime=TRUE(),1,
IF(direction="AMER"&&flightTime=TRUE(),1,
IF(direction="AMER"&& flightTime=FALSE(),0,
IF(code="V",BLANK(),
IF(direction="EMEA",BLANK()
))))))

 

Hope this able to help you.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.