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
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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.