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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Nested if statements

Hello,

 

EEGG19_1-1646932970039.png

 

I only get results for if not HoloLens and for the other if statement where operatingSystemNew = "HoloLens" I dont get any results. How can I do this correctly so I also get the results for if operatingSystemNew = "HoloLens".

 

Thanks 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Agree with @goncalogeraldes.

 

Please use SWITCH() to reduce nest IF() in your code, for example:

Windows versions =
SWITCH (
    TRUE (),
    [operatingSystemNEW] = "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.118362", [osVersion] < "10.0.18363" ),
            "1903",
            IF ( AND ( [osVersion] >= "10.0.18363", [osVersion] < "10.0.19042" ), "20H1" )
        ),
    [operatingSystemNEW] <> "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.18362", [osVersion] < "10.0.19041" ),
            "1903",
            IF (
                AND ( [osVersion] >= "10.0.19041.1103", [osVersion] < "10.0.19041.1128" ),
                "20H1"
            )
        )
)

Eyelyn9_0-1647329716990.png

 

Best Regards,
Eyelyn Qin
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

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Agree with @goncalogeraldes.

 

Please use SWITCH() to reduce nest IF() in your code, for example:

Windows versions =
SWITCH (
    TRUE (),
    [operatingSystemNEW] = "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.118362", [osVersion] < "10.0.18363" ),
            "1903",
            IF ( AND ( [osVersion] >= "10.0.18363", [osVersion] < "10.0.19042" ), "20H1" )
        ),
    [operatingSystemNEW] <> "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.18362", [osVersion] < "10.0.19041" ),
            "1903",
            IF (
                AND ( [osVersion] >= "10.0.19041.1103", [osVersion] < "10.0.19041.1128" ),
                "20H1"
            )
        )
)

Eyelyn9_0-1647329716990.png

 

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

Anonymous
Not applicable

Hi, thank you for your solution, it will solve my problem.

But as I want to add another line I get a syntax error.

EEGG19_0-1647441013808.png

How do I add more lines?

Thank you

@Anonymous , Based on @Anonymous  suggestion your additional condition goes like below:-

Windows versions =
SWITCH (
    TRUE (),
    [operatingSystemNEW] = "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.118362", [osVersion] < "10.0.18363" ),
            "1903",
            IF ( AND ( [osVersion] >= "10.0.18363", [osVersion] < "10.0.19042" ), "20H1" )
        ),
    [operatingSystemNEW] <> "HoloLens",
        IF (
            AND ( [osVersion] >= "10.0.18362", [osVersion] < "10.0.19041" ),
            "1903",
            IF (
                AND ( [osVersion] >= "10.0.19041.1103", [osVersion] < "10.0.19041.1128" ),
                "20H1"
            )
        ),
    [condition3] = "condition3", IF ( a = a, TRUE (), FALSE () )
)

 

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

goncalogeraldes
Super User
Super User

Hello there @Anonymous ! Have you tried using a SWITCH() in this case? It can heavily reduce and simplify your code 🙂 Try something in the lines of:

Windows Versions =
SWITCH(
   TRUE () ,
     condition1, result1,
     condition2, result2,
     ...,
     else
)

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors