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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JaweedL
Helper I
Helper I

Nested iF in Dax

Hi all

I am a simple expression to write, yet I am having a lot of trouble to translate in DAX, I must be doing someting consistently wrong. I seek your valuable help. Many thanks.

 

If  [Region]  in ( “NewYork”, “Louisana”)

{

                If [salesAmount] >[Target]

                {

                [value] = 0

                }

}

else    /* Different Region */

{

        If [salesAmount] < [Target]    /* Note check is different < */

                {

                [value]= 0

                }

}

2 ACCEPTED SOLUTIONS
dharmendars007
Super User
Super User

Hello @JaweedL , 

 

You can use Switch Function to simplify your If code in DAX, please try the below code..

 

Result =
SWITCH (
TRUE(),
AND ( OR ( [Region] = "NewYork", [Region] = "Louisana" ), [salesAmount] > [Target] ), 0,
AND ( NOT ( OR ( [Region] = "NewYork", [Region] = "Louisana" ) ), [salesAmount] < [Target] ), 0,[value])

 

If you find this helpful , please mark it as solution and Your Kudos/Likes are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

View solution in original post

ryan_mayu
Super User
Super User

@JaweedL 

what does [value]=0 mean?

 

maybe you can try something like below

 

If  ( [Region]  in { “NewYork”, “Louisana”} && salesAmount] >[Target] , XXXX , if ( NOT ([Region]  in { “NewYork”, “Louisana”} ) && [salesAmount] < [Target], XXXX))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
JaweedL
Helper I
Helper I

Thank you Dharmendar. It works, but I have difficulties to understand te code.

ryan_mayu
Super User
Super User

@JaweedL 

what does [value]=0 mean?

 

maybe you can try something like below

 

If  ( [Region]  in { “NewYork”, “Louisana”} && salesAmount] >[Target] , XXXX , if ( NOT ([Region]  in { “NewYork”, “Louisana”} ) && [salesAmount] < [Target], XXXX))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi ryan_mayu

Thank you. Works perfectly. Value was a meaure that I used for conditiinal formatting

 

dharmendars007
Super User
Super User

Hello @JaweedL , 

 

You can use Switch Function to simplify your If code in DAX, please try the below code..

 

Result =
SWITCH (
TRUE(),
AND ( OR ( [Region] = "NewYork", [Region] = "Louisana" ), [salesAmount] > [Target] ), 0,
AND ( NOT ( OR ( [Region] = "NewYork", [Region] = "Louisana" ) ), [salesAmount] < [Target] ), 0,[value])

 

If you find this helpful , please mark it as solution and Your Kudos/Likes are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors