Dax Function: WEEKDAY

Category: Date and Time Functions

The WEEKDAY function in Power BI is a DAX function that returns the day of the week corresponding to a date, represented as an integer. You can customize the numbering to start from any day (e.g., Sunday or Monday).

Purpose

To determine the day of the week from a date value.

Type of Calculations

Converts a date into an integer corresponding to a specific day of the week.

Practical Use Cases

  • Categorizing data by weekdays for reporting.
  • Filtering or grouping data by specific days of the week.
  • Performing date-based calculations such as business day identification.

WEEKDAY(<date>, [return_type])</date>

ParameterTypeDescription
dateScalarThe date value or column containing date values. Must be a valid date in Power BI.
return_typeOptionalDetermines the numbering system for the days of the week. Defaults to 1 if not provided.

How Does WEEKDAY Dax Function Works

The WEEKDAY function calculates the day of the week for a given date by referencing the Gregorian calendar. The optional return_type parameter specifies how the days are numbered:

Return TypeNumbering System
1 (default)Sunday = 1, Monday = 2, …, Saturday = 7
2Monday = 1, Tuesday = 2, …, Sunday = 7
3Monday = 0, Tuesday = 1, …, Sunday = 6

The result dynamically adjusts based on the provided return_type and refreshes with updates to the dataset.

What Does It Return?

  • Type: Integer.
  • Meaning: An integer that represents the day of the week for the specified date. The numbering format depends on the return_type parameter.

When Should We Use It?

  • Day Categorization: Group data by specific weekdays for trend analysis.
  • Business Operations: Filter out weekends or holidays for working-day calculations.
  • Visualizations: Create charts showing performance or trends for each day of the week.

Examples

Basic Usage

To determine the weekday for a specific date:


WeekdayExample = WEEKDAY(DATE(2025, 2, 10))  -- Default return type

Output: Returns 2 (Monday).

Column Usage:

Add a calculated column to find the weekday for each row in a date column:


WeekdayColumn = WEEKDAY(Table[OrderDate], 2)  -- Monday = 1, Sunday = 7

Output: Generates values like 1, 2, 3... representing the weekday.

Advanced Usage

Combine WEEKDAY with other functions to filter for weekends:


IsWeekend = IF(WEEKDAY(Table[OrderDate], 2) &gt; 5, "Weekend", "Weekday")

Output: Flags rows as “Weekend” or “Weekday.”

Tips and Tricks

  • Use return_type Carefully: Choose the return_type that aligns with your business logic or reporting standards.
  • Combine with Filters: Combine WEEKDAY with functions like FILTER to isolate specific days of the week.
  • Avoid Hardcoding: For flexibility, avoid hardcoding return_type unless consistent formatting is required.

Potential Pitfalls

  • Invalid Dates: Ensure that the date parameter contains valid date values; otherwise, errors may occur.
  • Default Behavior: Omitting the return_type defaults to Sunday as the first day, which may not align with all use cases.

Performance Impact of WEEKDAY DAX Function:

  • Efficient with small datasets but can increase calculation time if applied to large tables without filtering.
  • Use measures instead of calculated columns where possible to minimize storage overhead.

Related Functions You Might Need

  • DATE: Creates a date value from year, month, and day components.
  • FORMAT: Converts a date to a custom text format, including day names.
  • EOMONTH: Returns the end of the month for a given date.
  • NOW: Returns the current date and time.

Want to Learn More?
For more information, check out the official Microsoft documentation for WEEKDAY You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the WEEKDAY function return in Power BI?

It returns an integer representing the day of the week for a given date, customizable with the return_type.

2. How do I specify Monday as the first day of the week?

Use WEEKDAY(date, 2) to set Monday as 1 and Sunday as 7.

3. Can WEEKDAY filter weekends in Power BI?

Yes, combine WEEKDAY with IF or FILTER to identify or exclude weekends.

4. What happens if I omit the return_type parameter?

The function defaults to 1, where Sunday = 1 and Saturday = 7.

5. Is WEEKDAY compatible with custom calendars?

WEEKDAY is based on the Gregorian calendar. For custom calendars, additional logic is required.