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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
KW123
Helper V
Helper V

IF with &&& and ||

Hi! 

I have searched for awhile and I can't seem to find a solution.... I have a dashboard matrix which is broken out by Month in the columns.  Underneath each month is a ranking (from 1st - 200th depending on the month), a name,  # in sales, and $ in sales.  Each month there is a set of "favorite names" and they change depending on the month.  I need to be able to highlight those names within the month and I was thinking if I made some sort of DAX to distinguish these favorite names, I can do a conditional rule where that name is highlighted yellow. 

Basically the DAX that I am trying to build would go something like this: 

IF [month] = "January" OR "February"" AND [favorite name] = "John" or "Sam" or "Joe" (etc), then "F" else blank
IF [month] = "March" OR "APRIL" OR "MAY" AND [favorite name] = "Sue" OR "Anne" OR "Rose" then "F" else blank

ETC for each month.  

Thank you! 

2 ACCEPTED SOLUTIONS
SachinNandanwar
Super User
Super User

You could use a SWITCH statement

SWITCH(
TRUE(), 
(month = "January" || month = "February") &&  [favorite name] IN {John,Sam,Joe},
.
.
BLANK()
)

You can refine the above syntax.



Regards,
Sachin
Check out my Blog

View solution in original post

AlexisOlson
Super User
Super User

As @SachinNandanwar points out, using both SWITCH ( TRUE(), ... ) and IN syntax will help with this:

SWITCH (
    TRUE (),
    [month] IN { "January", "February" }
        && [favorite name] IN { "John", "Sam", "Joe" }, "F",
    [month] IN { "March", "April" }
        && [favorite name] IN { "Sue", "Anne", "Rose" }, "F",
    [ ... ],
    BLANK ()
)

 

DAX - The Diabolical Genius of “SWITCH TRUE” - P3 Adaptive

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

As @SachinNandanwar points out, using both SWITCH ( TRUE(), ... ) and IN syntax will help with this:

SWITCH (
    TRUE (),
    [month] IN { "January", "February" }
        && [favorite name] IN { "John", "Sam", "Joe" }, "F",
    [month] IN { "March", "April" }
        && [favorite name] IN { "Sue", "Anne", "Rose" }, "F",
    [ ... ],
    BLANK ()
)

 

DAX - The Diabolical Genius of “SWITCH TRUE” - P3 Adaptive

SachinNandanwar
Super User
Super User

You could use a SWITCH statement

SWITCH(
TRUE(), 
(month = "January" || month = "February") &&  [favorite name] IN {John,Sam,Joe},
.
.
BLANK()
)

You can refine the above syntax.



Regards,
Sachin
Check out my Blog

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Kudoed Authors