SAMEPERIODLASTYEAR

SAMEPERIODLASTYEAR

How to Use the Power BI DAX function SAMEPERIODLASTYEAR

What is the SAMEPERIODLASTYEAR Function?

The SAMEPERIODLASTYEAR function is a time intelligence function in Power BI that returns a table that contains a set of dates from the same period in the previous year. This function can be used to compare data from the current period with the data from the same period in the previous year. The result of the SAMEPERIODLASTYEAR function is a table that can be used in other calculations and visualizations.

Syntax of the SAMEPERIODLASTYEAR Function

The syntax of the SAMEPERIODLASTYEAR function is as follows:


SAMEPERIODLASTYEAR(❰Dates❱)


The ❰Dates❱ argument is a column that contains dates in the format YYYY-MM-DD. The SAMEPERIODLASTYEAR function returns a table that contains the same number of rows as the input table.

How to Use the SAMEPERIODLASTYEAR Function

To use the SAMEPERIODLASTYEAR function in Power BI, follow these steps:

1. Open Power BI and create a new report.

2. Import the data that you want to analyze.

3. Add a table or chart that displays the data that you want to compare.

4. Click on the table or chart to select it.

5. In the formula bar, type the following formula:


SAMEPERIODLASTYEAR(❰Dates❱)


Replace ❰Dates❱ with the name of the column that contains the dates that you want to compare.

6. Press Enter to apply the formula.

7. The function will return a table that contains the same number of rows as the input table but with the dates from the same period in the previous year.

8. Use the output of the SAMEPERIODLASTYEAR function in other calculations and visualizations.

Example of Using the SAMEPERIODLASTYEAR Function

Suppose you have a table that contains sales data for the year 2020. You want to compare the sales data for each month with the sales data for the same month in the year 2019. To do this, follow these steps:

1. Add a table or chart that displays the sales data for each month in the year 2020.

2. Click on the table or chart to select it.

3. In the formula bar, type the following formula:


SAMEPERIODLASTYEAR(Sales[Date])


Replace Sales[Date] with the name of the column that contains the dates for the sales data.

4. Press Enter to apply the formula.

5. The function will return a table that contains the sales data for each month in the year 2019.

6. Use the output of the SAMEPERIODLASTYEAR function in other calculations and visualizations.

The SAMEPERIODLASTYEAR function is a powerful feature of Power BI that allows you to compare data from the same period in the previous year. This function can be particularly useful when analyzing trends and seasonality in your data. By following the steps outlined in this article, you can use the SAMEPERIODLASTYEAR function to compare data and gain 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)

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: