Syntax of the MONTH Function
The syntax of the MONTH function is as follows:
Here, `❰date❱` is the column or expression that represents a date value. The MONTH function extracts the month from the date value and returns an integer value between 1 and 12.
Examples of Using the MONTH Function
Let's take a look at some examples of using the MONTH function in Power BI.
Example 1: Extracting Month from a Date Column
Suppose we have a dataset that contains a column named "Date" that stores date values. We want to extract the month from this column and create a new column named "Month" that contains the month number. To do this, we can use the following DAX expression:
Month = MONTH([Date])
This expression creates a new column named "Month" that contains the month number extracted from the "Date" column. We can now use this column to analyze and visualize data in a report.
Example 2: Using the MONTH Function in a Measure
Suppose we have a dataset that contains a column named "Sales" that stores sales data, and a column named "Date" that stores date values. We want to create a measure that calculates the total sales for each month. To do this, we can use the following DAX expression:
Total Sales = SUM([Sales])
Sales by Month = CALCULATE([Total Sales], MONTH([Date]))
This expression creates a measure named "Sales by Month" that calculates the total sales for each month. The MONTH function is used as a filter to calculate the sales for each month.
The MONTH function in Power BI is a powerful tool that allows you to extract the month from a date value and use it in analysis and visualization. By using this function, you can perform various analyses, such as calculating total sales by month, analyzing trends, and more. We hope this article has helped you understand how to use the MONTH function in Power BI.
Power BI DAX Training Courses by G Com Solutions (0800 998 9248)
Power BI DAX Intensive Training Course£1,050.00 – £26,550.00
Power BI DAX Introduction£395.00 – £9,750.00
Power BI DAX Intermediate£395.00 – £9,750.00
Power BI DAX Advanced£395.00 – £9,750.00