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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
cdawidow
Helper III
Helper III

Nested If Statements

Hi guys, I have 4 measures each recieving a final alpha grade (A,B,C,D).  I want to use an IF statement to essentially select specific outcomes for these measures that would match or equal a select outcome.  For reference my measures are as follows: 

Customer NameCustomer Sales RankLoyalty MeasureMargin Finalcts
xxxAAAC
yyyyAAAB
vcvABDD

 

So for a good customer, they need to have either an A OR B in both sales, loyalty, margin, but a c or d scoring in cts.

As for a potential good customer, they need to have A OR B in margin, but C & D in the rest of the factors.

 

I have used the following measure but I still get stuck.  

IF(SALES RANK = "A" || SALS RANK "B" && MARGIN FINAL = "A"||MARGIN FINAL = B ETC......

 

I have used the OR operators and && operators but I still sometimes do not get the correct grouping.  Any ideas?

3 REPLIES 3
amitchandak
Super User
Super User

@cdawidow , Try like

switch( true(),
[Customer Sales] in {"A","B"} && [Rank Loyalty] in {"A","B"} && [Measure Margin] in {"A","B"} && [Final cts] in {"C","D"} , "Good",
"Bad"
)

 

or a measure like

maxx(summarize( Table, Table[Customer Name], "Rank" ,
switch( true(),
[Customer Sales] in {"A","B"} && [Rank Loyalty] in {"A","B"} && [Measure Margin] in {"A","B"} && [Final cts] in {"C","D"} , "Good",
"Bad"
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Fowmy
Super User
Super User

@cdawidow 

Try this measure and replace the column names with your measure names:

Measure = 

IF(
    (
        MAX(DATA1[Customer Sales Rank]) IN {"A","B"} && 
        MAX(DATA1[Loyalty Measure]) IN {"A","B"} && 
        MAX(DATA1[Margin Final]) IN {"A","B"} 
    ) &&
    (
        MAX(DATA1[cts]) IN {"A","B","C","D"}
    ), 
    "GOOD",
    IF(
        (
            MAX(DATA1[Customer Sales Rank]) IN {"A","B"} && 
            MAX(DATA1[Loyalty Measure]) IN {"A","B"} 
        ) &&
        (
            MAX(DATA1[Margin Final]) IN {"A","B","C","D"} && 
            MAX(DATA1[cts]) IN {"A","B","C","D"}
        ),
    "POTENTIAL"
    )
)

 

Fowmy_0-1598299217123.png

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube, LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

sturlaws
Resident Rockstar
Resident Rockstar

Hi @cdawidow 

 

You get the wrong answers because your are not grouping your 'or' statements together with paranthesis.

 

You can also try to rewrite your measure using the 'IN'-function:

IF([SALES RANK] in ("A","B") && [MARGIN FINAL] in ("A","B") && [LOYALTY] in ("A","B") && [FINALCTS] in ("C","D")

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.