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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

If formula error

Hi expert

 

I cannot see my error here..

Margin Range = if('Fact_Net_Billing'[Net Margin (%)]<=.1,"<10%",

                    if(AND('Fact_Net_Billing'[Net Margin (%)]>=.10 && 'Fact_Net_Billing'[Net Margin (%)]<=.2,"10-20%"),

                        if(AND('Fact_Net_Billing'[Net Margin (%)]>=.2 && 'Fact_Net_Billing'[Net Margin (%)]<=.4,"20-40%"), ">40%")))

 

1 ACCEPTED SOLUTION
PC2790
Community Champion
Community Champion

Hi @Anonymous ,

 

There is no need of applying the AND operation twice by adding 'AND' & '&&'.

Try removing one, something like:

Margin Range =
IF (
    [NetMargin] <= .1,
    "<10%",
    IF (
        
            [NetMargin] >= .10
                && [NetMargin] <= .2,
            "10-20%"
        ,
        IF (
            
                [NetMargin] >= .2
                    && [NetMargin] <= .4,
                "20-40%"
            ,
            ">40%"
        )
    )
)

Also, looking at your requirement, I would suggest using a Switch statement here which would look something like this:

Margin Range =
SWITCH (
    TRUE (),
    [NetMargin] <= 0.1, "<10%",
    AND ( [NetMargin] >= .10, [NetMargin] ) <= .2, "10-20%",
    AND ( [NetMargin] >= .2, [NetMargin] ) <= .4, "20-40%",
    ">40%"
)

I hope this helps

View solution in original post

2 REPLIES 2
PC2790
Community Champion
Community Champion

Hi @Anonymous ,

 

There is no need of applying the AND operation twice by adding 'AND' & '&&'.

Try removing one, something like:

Margin Range =
IF (
    [NetMargin] <= .1,
    "<10%",
    IF (
        
            [NetMargin] >= .10
                && [NetMargin] <= .2,
            "10-20%"
        ,
        IF (
            
                [NetMargin] >= .2
                    && [NetMargin] <= .4,
                "20-40%"
            ,
            ">40%"
        )
    )
)

Also, looking at your requirement, I would suggest using a Switch statement here which would look something like this:

Margin Range =
SWITCH (
    TRUE (),
    [NetMargin] <= 0.1, "<10%",
    AND ( [NetMargin] >= .10, [NetMargin] ) <= .2, "10-20%",
    AND ( [NetMargin] >= .2, [NetMargin] ) <= .4, "20-40%",
    ">40%"
)

I hope this helps

PhilipTreacy
Super User
Super User

Hi @Anonymous 

You'e using both AND() and && when you only need one of these.

Try this instead

 

Margin Range = if('Fact_Net_Billing'[Net Margin (%)] <= .1, "<10%",

                    if(AND('Fact_Net_Billing'[Net Margin (%)] >= .10 , 'Fact_Net_Billing'[Net Margin (%)] <= .2) ,"10-20%",

                        if(AND('Fact_Net_Billing'[Net Margin (%)] >= .2 , 'Fact_Net_Billing'[Net Margin (%)] <= .4),"20-40%", ">40%")))

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.