Trouble with If AND statement in DAX

Hello,

I am having some issues with an IF AND statement in Dax. Below is what I am looking to achieve written in sentence form. “ScheduledDays” is my variable.

If(ScheduledDays = 0 And (WEEKDAY(today()+8=1) or WEEKDAY(Today()+8=7)),“Weekend111”, “False”)

Any guidance is appreciated!

Thanks!
Preston

Hi @Preston,

See if this is what you are after.

IF(
    ScheduledDays = 0 && WEEKDAY( TODAY()) + 8 = 1 || 
	ScheduledDays = 0 && WEEKDAY( TODAY()) + 8 = 7,
    "Weekend111",
    "False"
)
1 Like

Hi @Preston,

Though @Melissa replied before me but still I am adding the code as you just need to add bracket after AND as shown in below figure. Also have replaced And with && and or with || because with this you can have any number of arguments with sequence.

If(
    ScheduledDays = 0 
    && ( (WEEKDAY(today()+8=1) || WEEKDAY(Today()+8=7)) ),
    "Weekend111", 
    "False"
)

Hi @Preston, we’ve noticed that no response has been received from you since the 24th of October. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!

This is not working…I will explain my goal here. I have a field which is sometimes blank with a few commas, field name (Workticketstepheadermerge[Employees]). I want to check this field and when it has employee names in it I want to display them, but when It doesn’t I want to display “Weekend111” rather than just blank’s with commas. Also, to through another wrench in it I only want to do this if the field that I am calculating Ex. Weekday(today)+8 is on a weekend.

Attached is the .pbix, see the calculated column called “8DaysAhead” which is where I am trying to accomplish this. I have it currently looking for every letter of the alphabet and when it doesn’t see anything from the alphabet we can assume that its blank, so return “Weekend111”.

Currently my logic is not working, any help is appreciated!

Thanks!
PrestonAssemblySchedule - Copy.pbix (660.5 KB)

@Preston
I replaced the measure looking for employee name in Workticketstepheadermerge[Employees]
8DaysAhead =

Var ScheduledDays =

IFERROR(Search(“a”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“b”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“c”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“d”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“e”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“f”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“g”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“h”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“i”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“j”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“k”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“l”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“m”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“n”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“o”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“p”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“q”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“r”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“s”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“t”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“u”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“v”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“w”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“x”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“y”,Workticketstepheadermerge[Employees]),0) &

IFERROR(Search(“z”,Workticketstepheadermerge[Employees]),0)

Return

//ScheduledDays

If(

ScheduledDays = 0

&& ( (WeekDay(Today()+8=1) || WEEKDAY(Today())+8=7)),

“Weekend111”,

“False”

)

With the following measure:

8DaysAhead =
Var ScheduledDays =
IF(
LEN(Workticketstepheadermerge[Employees]),
0,
BLANK())

Return
//ScheduledDays
If(
ScheduledDays = 0
&& ( (WeekDay(Today()+8=1) || WEEKDAY(Today())+8=7)),
“Weekend111”,
“False”
)

As you mentioned

If the field has commas then it is not Blank. It is a good practice to Trim & Clean your columns so they only have the desired data in them.
I am attaching the file and let me know if this is what you are looking for.
AssemblySchedule - Fixed.pbix (640.5 KB)

Thanks.

1 Like