SAMEPERIODLASTYEAR
A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
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.