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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Switch Formula error message

Hello, 

 

Using the following formula (adding calculated column to my date table) which I thought should work, but getting an error message.   If I just put  Blank() )   the syntax does not show me any error message when writing the formula, but as soon as I hit enter, it adds all of these  )))))) with the last one showing the dreaded red squiggly line and then this error message.  

 

Any ideas why?    Am I perhaps missing something after the Blank() ?   

 

Annotation 2020-02-19 163016.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I answered my own question.   

 

Did not need to put "DATE" in front.    And did not need parenthesis.  

 

 

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hello @Anonymous 

DATE() function returns a date and will require these numeric inputs: Year, Month, Day. You may use the simplied formula below:

Weekend or Weekday =
IF (
    DataTable[DayInWeek] = 0
        || DataTable[DayInWeek] = 6,
    "Weekend",
    "Weekday"
)

Or use a longer one:

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

 










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


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

@Anonymous , DATE() is a function that returns a date when you supply a year, month, and day.

 

DATE(2020, 2, 14) returns February 14, 2020, formatted as a date.

 

This calculated column will give you what you're looking for:

 

Weekend or Weekday = 
IF(
	DateTable[DayInWeek] = 0
		|| DateTable[DayInWeek] = 6
	,"Weekend"
	,"Weekday"
)
KHorseman
Community Champion
Community Champion

You didn't close the parentheses on all those DATE( formulas. Should be DATE(DateTable[DayInWeek]).





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

Proud to be a Super User!




Anonymous
Not applicable

I answered my own question.   

 

Did not need to put "DATE" in front.    And did not need parenthesis.  

 

 

Anonymous
Not applicable

I tried that....but immediately get a red line....??
 
red line.png
 
 

 

Oh right, I think you want DAY, not DATE.





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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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