on 08-22-2023 01:11 PM - edited on 08-24-2023 02:49 PM by Tristan
If you want to convert a date to a weekday name (Monday, Tuesday, Wednesday, etc.) there are two common approaches:
When dragging a date into a tray, open the settings to expose formatting options. In the date mask field, enter 'EEE' for an abbreviated weekday (Mon) and 'EEEE' for a full weekday name (Monday). More masking options are available here.
Bonus fact: based on the mask entered, you'll have a preview of the output in the date format dropdown!
To build a formula, look no further than the formatDate() built-in function. For this formula to properly execute, you must provide a data column and the string mask of a desired format.
formatDate(date exp,string mask)
Example:
formatDate(
Online_Store.OrderDetails.OrderDate,
'EEEE'
)
Quick tip: instead of formatting the output data by trial and error, use the formatting method above until you get the correct mask set, then copy and paste it into the formula!
If the format option is used, the underlying date will be considered distinct and not aggregate at the weekday level. A formula will remove the underlying value, leaving the output to be aggregated by the day of the week.
To best illustrate the difference - take these ten records:
When applying format only on an aggregated table, the data will appear as:
Notice that there are multiple instances of Thursday, Friday, and Saturday.
Now see what happens when the data is formatted with a formula:
7 rows for 7 days! Ensuring you choose the right method can drastically change the meaning of your analysis.