SWITCH formula (from Sam's video)

Hello - I copied this formula from one of Sam’s videos talking about Weekends and Weekdays.

But I get an error message. In fact, what happens is that when I hit “enter”, the formula changes and adds )))))) with a red line under the last one. And it’s telling me the minimum argument is 3.

Any idea why?

Weekend or Weekday = SWITCH(TRUE(),

DATE(DateTable[DayInWeek] = 1, “Weekday”,

DATE(DateTable[DayInWeek] = 2, “Weekday”,

DATE(DateTable[DayInWeek] = 3, “Weekday”,

DATE(DateTable[DayInWeek] = 4, “Weekday”,

DATE(DateTable[DayInWeek] = 5, “Weekday”,

DATE(DateTable[DayInWeek] = 6, “Weekend”,

DATE(DateTable[DayInWeek] = 0, “Weekend”,

BLANK() )

@richmont,

You don’t need the DATE() function here. This should work as a calculated column:

Weekend Weekday =

SWITCH (
    TRUE (),
    DateTable[DayInWeek] = 1, "Weekday",
    DateTable[DayInWeek] = 2, "Weekday",
    DateTable[DayInWeek] = 3, "Weekday",
    DateTable[DayInWeek] = 4, "Weekday",
    DateTable[DayInWeek] = 5, "Weekday",
    DateTable[DayInWeek] = 6, "Weekend",
    DateTable[DayInWeek] = 0, "Weekend",
    BLANK ()
)

As a measure , you will need to wrap each DateTable[DayInWeek] in SELECTEDVALUE(). I would recommend doing this as a calculated column in your date table using the code above (or alternatively doing it in Power Query).

Hope this is helpful.

  • Brian
1 Like

Thanks Brian!! Was trying to do it from memory and that was indeed the problem.

Cheers!