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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
benjaminlvdr
New Member

DAX

Hi everyone,

 

Can you help to debug this formula please ?

 

IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]<5);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]>5);"delay";IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]<10);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]>10));"delay";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]<15);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]>15);"delay";)))))

Thanks a lot,

Benjamin

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @benjaminlvdr,

 

As @parry2k said this is not the best way to have your question answer however I believe I have found your error check the bold part below, you have 2 brackets in the middle of your formula closing it earlier than you need.

 

 

IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]<5);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]>5);"delay";IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]<10);"on-time";
IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]>10)) <- this bracket is to much
;"delay";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]<15);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]>15);"delay"Smiley Wink))))

 

 

On best practices your formula should be written like this:

Formula =
IF (
    AND (
        Tableau_owssvr_1[Project complexity] = "simple";
        Tableau_owssvr_1[Adressed request time] < 5
    );
    "on-time";
    IF (
        AND (
            Tableau_owssvr_1[Project complexity] = "simple";
            Tableau_owssvr_1[Adressed request time] > 5
        );
        "delay";
        IF (
            AND (
                Tableau_owssvr_1[Project complexity] = "medium";
                Tableau_owssvr_1[Adressed request time] < 10
            );
            "on-time";
            IF (
                AND (
                    Tableau_owssvr_1[Project complexity] = "medium";
                    Tableau_owssvr_1[Adressed request time] > 10
                );
                "delay";
                IF (
                    AND (
                        Tableau_owssvr_1[Project complexity] = "complex";
                        Tableau_owssvr_1[Adressed request time] < 15
                    );
                    "on-time";
                    IF (
                        AND (
                            Tableau_owssvr_1[Project complexity] = "complex";
                            Tableau_owssvr_1[Adressed request time] > 15
                        );
                        "delay";
                        ""
                    )
                )
            )
        )
    )
)

don't know what the smiley face in the end represent I placed a "".

 

But to improve overall legebility and performance you should redo your measure to this:

ttt =
SWITCH (
    TRUE ();
    Tableau_owssvr_1[Project complexity] = "simple"
        && Tableau_owssvr_1[Adressed request time] < 5; "on-time";
    Tableau_owssvr_1[Project complexity] = "simple"
        && Tableau_owssvr_1[Adressed request time] > 5; "delay";
    Tableau_owssvr_1[Project complexity] = "medium"
        && Tableau_owssvr_1[Adressed request time] < 10; "on-time";
    Tableau_owssvr_1[Project complexity] = "medium"
        && Tableau_owssvr_1[Adressed request time] > 10; "delay";
    Tableau_owssvr_1[Project complexity] = "complex"
        && Tableau_owssvr_1[Adressed request time] < 15; "on-time";
    Tableau_owssvr_1[Project complexity] = "complex"
        && Tableau_owssvr_1[Adressed request time] > 15; "delay";
    ""
)

As you can see it's much shorte and easier to read, again the "" on the end should be replace by what you have on your smiley face.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @benjaminlvdr,

 

Agree with MFelix.

 

Have you solved your problem?

 

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

In addition, you could use this dax format tool to check if your dax formulas have syntax error.

 

If you still need help, please feel free to ask.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @benjaminlvdr,

 

As @parry2k said this is not the best way to have your question answer however I believe I have found your error check the bold part below, you have 2 brackets in the middle of your formula closing it earlier than you need.

 

 

IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]<5);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="simple";Tableau_owssvr_1[Adressed request time]>5);"delay";IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]<10);"on-time";
IF(AND(Tableau_owssvr_1[Project complexity]="medium";Tableau_owssvr_1[Adressed request time]>10)) <- this bracket is to much
;"delay";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]<15);"on-time";IF(AND(Tableau_owssvr_1[Project complexity]="complex";Tableau_owssvr_1[Adressed request time]>15);"delay"Smiley Wink))))

 

 

On best practices your formula should be written like this:

Formula =
IF (
    AND (
        Tableau_owssvr_1[Project complexity] = "simple";
        Tableau_owssvr_1[Adressed request time] < 5
    );
    "on-time";
    IF (
        AND (
            Tableau_owssvr_1[Project complexity] = "simple";
            Tableau_owssvr_1[Adressed request time] > 5
        );
        "delay";
        IF (
            AND (
                Tableau_owssvr_1[Project complexity] = "medium";
                Tableau_owssvr_1[Adressed request time] < 10
            );
            "on-time";
            IF (
                AND (
                    Tableau_owssvr_1[Project complexity] = "medium";
                    Tableau_owssvr_1[Adressed request time] > 10
                );
                "delay";
                IF (
                    AND (
                        Tableau_owssvr_1[Project complexity] = "complex";
                        Tableau_owssvr_1[Adressed request time] < 15
                    );
                    "on-time";
                    IF (
                        AND (
                            Tableau_owssvr_1[Project complexity] = "complex";
                            Tableau_owssvr_1[Adressed request time] > 15
                        );
                        "delay";
                        ""
                    )
                )
            )
        )
    )
)

don't know what the smiley face in the end represent I placed a "".

 

But to improve overall legebility and performance you should redo your measure to this:

ttt =
SWITCH (
    TRUE ();
    Tableau_owssvr_1[Project complexity] = "simple"
        && Tableau_owssvr_1[Adressed request time] < 5; "on-time";
    Tableau_owssvr_1[Project complexity] = "simple"
        && Tableau_owssvr_1[Adressed request time] > 5; "delay";
    Tableau_owssvr_1[Project complexity] = "medium"
        && Tableau_owssvr_1[Adressed request time] < 10; "on-time";
    Tableau_owssvr_1[Project complexity] = "medium"
        && Tableau_owssvr_1[Adressed request time] > 10; "delay";
    Tableau_owssvr_1[Project complexity] = "complex"
        && Tableau_owssvr_1[Adressed request time] < 15; "on-time";
    Tableau_owssvr_1[Project complexity] = "complex"
        && Tableau_owssvr_1[Adressed request time] > 15; "delay";
    ""
)

As you can see it's much shorte and easier to read, again the "" on the end should be replace by what you have on your smiley face.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



parry2k
Super User
Super User

@benjaminlvdr what is the issue?

 

Please use this link to  a pors on how to get your question answered quickly.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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