DAY

How to Use the Power BI DAX function DAY

What Is the DAY Function?

The DAY function is a DAX function that allows you to extract the day from a given date. The syntax of the function is as follows:


DAY(❰date❱)


Where ❰date❱ is the date from which you want to extract the day. The function returns an integer value between 1 and 31, which represents the day of the month.

Using the DAY Function in Power BI

To use the DAY function in Power BI, you need to start by creating a new measure or column. Let's say you have a table with a column named "Date" that contains dates in the format "MM/DD/YYYY". To create a new column that extracts the day from each date, you can use the following formula:


DayOfMonth = DAY([Date])


This will create a new column named "DayOfMonth" that contains the day of the month for each date in the "Date" column.

If you want to create a measure that calculates the total sales for a specific day of the month, you can use the following formula:


SalesForDay = CALCULATE(SUM([Sales]), DAY([Date]) = 15)


This will create a measure named "SalesForDay" that calculates the total sales for the 15th day of the month. You can change the day number to any other value, or use a variable instead, to calculate sales for a different day.

You can also use the DAY function in combination with other DAX functions, such as DATEADD and DATEDIFF. For example, to calculate the number of days between two dates, you can use the following formula:


DaysBetween = DATEDIFF([Start Date], [End Date], DAY)


This will create a measure named "DaysBetween" that calculates the number of days between the "Start Date" and "End Date" columns.

The Power BI DAX function DAY is a useful tool for working with dates. It allows you to extract the day from a given date and use it in various calculations. By using this function in combination with other DAX functions, you can create powerful measures and columns that provide valuable insights into your data.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)