YEAR

YEAR

How to Use the Power BI DAX function YEAR

In this article, we will explore how to use the Power BI DAX function YEAR and provide some examples to help you get started.

What is the Power BI DAX function YEAR?

The Power BI DAX function YEAR is a date and time function that extracts the year from a given date. This function takes a date column or a date-time column as input and returns the year as an integer.

Syntax of the Power BI DAX function YEAR

The syntax of the Power BI DAX function YEAR is as follows:


YEAR(❰date❱)


The ❰date❱ argument is the date column or date-time column from which you want to extract the year.

Examples of using the Power BI DAX function YEAR

Let's look at some examples of how to use the Power BI DAX function YEAR.

Example 1: Extracting the year from a date column

Suppose you have a table that contains a date column, and you want to extract the year from that column. You can use the following DAX formula:


=YEAR(Table1[Date])


Here, Table1 is the name of the table, and Date is the name of the date column.

Example 2: Extracting the year from a date-time column

Suppose you have a table that contains a date-time column, and you want to extract the year from that column. You can use the following DAX formula:


=YEAR(Table1[DateTime])


Here, Table1 is the name of the table, and DateTime is the name of the date-time column.

Example 3: Using the YEAR function with other functions

You can also use the YEAR function in combination with other functions. For example, suppose you have a table that contains a date column, and you want to calculate the total sales for each year. You can use the following DAX formula:


=SUMX(

FILTER(

Table1,

YEAR(Table1[Date]) = 2022

),

Table1[Sales]

)


Here, SUMX is a function that calculates the sum of an expression for each row in a table, FILTER is a function that filters a table based on a condition, and Table1 is the name of the table.

The formula calculates the total sales for the year 2022 by first filtering the table to include only the rows where the year is 2022, and then summing up the sales for those rows.

The Power BI DAX function YEAR is a powerful tool that allows you to extract the year from a date. It can be particularly useful when working with large data sets, as it can save you a lot of time and effort. By using the examples provided in this article, you can start using the YEAR function in your own Power BI reports and dashboards.

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)

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: