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
Haidarius
Frequent Visitor

Nested IF functions in DAX power bi

So I have this logic from crystal reports formula builder that I'd like to follow into powerBI's DAX and create a new column with the result:

if {tableA.Col1} = "PAY" and {tableB.Col#} in ["LEG", "HAND"] and {tableA.Col2} = "Y" then "N" else "Y"

I cant seem to create any logical statement to refer to another table within DAX (up to my knowledge) or actually nest multiple ifs like above, here is what I have so far..

Error = IF(tableA[col1] = "PAY" && IF(tableB[col#] = "LEG"&&"HAND" && IF(tableA[col2] = "Y","N","Y"),"Y"),"Y")

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

If tableB is on the one side of a relationship with table A then you can use the RELATED function. 

The table constructor in DAX is { }, so you could create your new column like

Error Column =
IF (
    tableA[col1] = "PAY"
        && RELATED ( tableB[col#] )
            IN { "HANDS", "LEGS" }
            && tableA[col2] = "Y",
    "Y",
    "N"
)

View solution in original post

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

I am not sure I understood the issue but here are some general pointers:

For nested ifs I would use SWITCH + TRUE structure. E.g.
SWITCH(TRUE(),
condition 1, result 1,
condition 2, result 2...)

If you want to use multiple tables in one expression make sure your realtionships are functional and use expressions such as RELATED.





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

Proud to be a Super User!




tamerj1
Super User
Super User

Hi @Haidarius 

please try

=
IF (
    SELECTEDVALUE ( tableA[Col1] ) = "PAY"
        && SELECTEDVALUE ( tableB[Col#] )
            IN { "LEG", "HAND" }
                && SELECTEDVALUE ( tableA[Col2] ) = "Y",
    "N",
    "Y"
)
johnt75
Super User
Super User

If tableB is on the one side of a relationship with table A then you can use the RELATED function. 

The table constructor in DAX is { }, so you could create your new column like

Error Column =
IF (
    tableA[col1] = "PAY"
        && RELATED ( tableB[col#] )
            IN { "HANDS", "LEGS" }
            && tableA[col2] = "Y",
    "Y",
    "N"
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.