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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Help with IF Statement Measure that uses AND and OR

FileID    Employee    Concerns     Reason 1     Reason 2    Reason 3

1                John         Yes            

2            Emily            No

3              Henry         Yes               health          fatigue

 

 

I'm wanting to create an IF statement that will return the FileID and the employee name when I insert this measure into a matrix that has the emploees in the row section and file ID for the columns 

** or a calculated column that will return a value on every row if the below if statement is true 

 

The IF statement will check to see if Concerns = "Yes" and then check to see if Reason 1, Reason 2 or Reason 3 are blank

I want to see an error made by employees when filling out the form to make sure if they are filling out "yes" for concerns that they are then filling out either reason 1, reason 2 or reason 3 any of them can be filled in but at least one

So something like IF(concerns = "yes" then return 1 if Reason 1 or reason 2 or reason 3 are blank 

and the opposite as well IF(concerns = "no" then all the fields (reason 1, reason 2, and reason 3 should ALL be blank) 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can refer to the DAX below:

Y =
IF (
    MAX ( 'Table'[Concerns] ) = "Y"
        && (
            NOT ( MAX ( 'Table'[Reason 1] ) = "" )
                || NOT ( MAX ( 'Table'[Reason 2] ) = "" )
                || NOT ( MAX ( 'Table'[Reason 3] ) = "" )
        ),
    1,
    IF (
        MAX ( 'Table'[Concerns] ) = "N"
            && MAX ( 'Table'[Reason 1] ) = ""
            && MAX ( 'Table'[Reason 2] ) = ""
            && MAX ( 'Table'[Reason 3] ) = "",
        1
    )
)

test_0311.PNG

If I misunderstood, please provide the result you expect.

 

Best Regards,
Liang
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
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can refer to the DAX below:

Y =
IF (
    MAX ( 'Table'[Concerns] ) = "Y"
        && (
            NOT ( MAX ( 'Table'[Reason 1] ) = "" )
                || NOT ( MAX ( 'Table'[Reason 2] ) = "" )
                || NOT ( MAX ( 'Table'[Reason 3] ) = "" )
        ),
    1,
    IF (
        MAX ( 'Table'[Concerns] ) = "N"
            && MAX ( 'Table'[Reason 1] ) = ""
            && MAX ( 'Table'[Reason 2] ) = ""
            && MAX ( 'Table'[Reason 3] ) = "",
        1
    )
)

test_0311.PNG

If I misunderstood, please provide the result you expect.

 

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

Ashish_Mathur
Super User
Super User

Hi,

I would suggest that in the query editor, you select t he first 3 columns, right click on the column heading and select "Unpivot other columns".  Then you drag File ID and Name to the visual.  To your visual, drag Attribute to the filter/slicer and select Yes.  Drag File ID to the row labels.  This should show you all those File ID who answered Yes and recorded some reason.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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