Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

SamePeriodLastYear() - Visual Level Filters

I need to filter on the previous value and not the current...?I need to filter on the previous value and not the current...?

When Slicing by a Year, my table shows the previous Year Value using the SAMEPERIODLASTYEAR function (MeasureSPLY).

I then want to use the Visual Level Filters, but the value shown in the table is not there, only the sliced Year value is?

Is there a way round this?

 

Much obliged.

7 REPLIES 7
ryan_mayu
Super User
Super User

@Anonymous

 

Have you bulded the relationship between two tables by using date column?

c1.JPG

 

If you did that, you won't see year 2018.

 

LY = CALCULATE(SUM('fact'[amount]),SAMEPERIODLASTYEAR('date'[date]))

 

c2.JPG

 

 

I am curious that why you select 2019,  you still can see 2018/1/1 in your table. The value of same period last year should in the same row as 2019/1/1.

 

I think the reason why you can't see 2018 in the visual filter is because you have already choose 2019 in the year filter.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thanks for the response.

 

The reason I could see 2018 in the table is because the Cross Filter direction Relationship from my Calendar table to Table1 was set to Single.  If I change it to Both, 2018 is no longer displayed, but Value is not displayed in MeasureSPLY?

 

SamePeriodLastYear2.png

 

 

 

 

 

hi, @Anonymous

First, you should know that SamePeriodLastYear is corresponding to current row context.

If there are other years in your date table, it will return SamePeriodLastYear of each of them.

For example:

current year - SamePeriodLastYear

2020            - 2019

2019            - 2018

2018            - 2017

...

And from your screen, there is no value in 2018 for [measure],

so for SamePeriodLastYear of 2019, there is no value of [measureSPLY]

 

BTW: you need to learn about row context of DAX, It may help you understand it well.

 

Best Regards,

Lin

 

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Many thanks for the response. I can't seem to upload photos, even though I'm signed in?? My data looks like this and has a measure value for each year: Date DimensionA DimensionB Measure1 01 January 2018 A2018 B2018 10 01 January 2019 A2019 B2019 20 01 January 2020 A2020 B2020 30 This appears to only work when Cross filter direction is set to Single. When I select 2020 from the slicer, my tables shows as expected the previous year values for 2019. This is because SAMEPERIODLASTYEAR is used in the measure MeasureSPLY. Date DimensionA DimensionB MeasureSPLY 01/01/2019 00:00 A2019 B2019 20 My question is, if I want to filter this further using Visual Filters, is there anyway to see the previous Year values shown in the table? Since the only values available in the Visual Filter are the 2020 values? Hope this makes sense. Many thanks
Anonymous
Not applicable

Many thanks for the response. I can't seem to upload photos, even though I'm signed in?? My data looks like this and has a measure value for each year: Date DimensionA DimensionB Measure1 01 January 2018 A2018 B2018 10 01 January 2019 A2019 B2019 20 01 January 2020 A2020 B2020 30 This appears to only work when Cross filter direction is set to Single. When I select 2020 from the slicer, my tables shows as expected the previous year values for 2019. This is because SAMEPERIODLASTYEAR is used in the measure MeasureSPLY. Date DimensionA DimensionB MeasureSPLY 01/01/2019 00:00 A2019 B2019 20 My question is, if I want to filter this further using Visual Filters, is there anyway to see the previous Year values shown in the table? Since the only values available in the Visual Filter are the 2020 values? Hope this makes sense. Many thanks
Anonymous
Not applicable

I'll try again... This time on IE which allows me to upload photos, when Chrome and Edge don't?

 

Anyway,  many thanks for the response.

 

My data looks like this and has a measure value for each year:

 

07-01-2019 11-10-59.png

 

This appears to only work when Cross filter direction is set to Single.

 

07-01-2019 12-44-13.png

 

When I select 2020 from the slicer, my tables shows as expected the previous year values for 2019. This is because SAMEPERIODLASTYEAR is used in the measure MeasureSPLY.

07-01-2019 11-46-11.png

My question is, if I want to filter this further using Visual Filters, is there anyway to see the previous Year values shown in the table?

 

Since the only values available in the Visual Filter are the 2020 values?

 

07-01-2019 12-49-49.png

 

 

 

Hope this makes sense.

 

Many thanks 

hi, @Anonymous

Since SamePeriodLastYear is a time-intelligence function, It needs a date time, and all the time dimension should from

date table. from your screenshot we could know that date, DimensionA, DimensionB is from data table. It couldn't be done

by this. DimensionA, DimensionB should be defined in date table.

In the visual, they should be "Tag attributes" not "time dimension". and when you filter current context you could see current context data. for example: when you filter 2020, you could only see data in 2020, and use SamePeriodLastYear is just retrun 2019 data for 2020.

Here are some documents for your reference:

https://support.office.com/en-us/article/context-in-dax-formulas-2728fae0-8309-45b6-9d32-1d600440a7ad

http://www.statslab-bi.co.nz/project/row-filter-context-dax/

 

Best Regards,
Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors