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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Gem42
New Member

DAX Expression for Time Periods

Hi,

 

I am really struggling and hoping someone maybe able to help please.

 

I have a table of data with information ranging from 2022 – 2024.

 

In the PowerBI Dashboard, I want to show a Table visual which shows the total sales for 2024 vs the total sales for 2023.  I have also put a slicer on the page which allows the month that is displayed in the table visual to be selected. 

 

As a measure I have used the SAMPERIODLASTYEAR function to obtain the 2023 data, and if January is selected from the slicer, January 2023 is just shown, similarly if I select February only February 2023 is displayed and if I select both January and February I see February 2023 YTD data.

 

However for the 2024 data I can not figure out what the correct expression is that will give me January 2024 only, February 2024 only or January 2024 and February 2024 combined depending on which months are selected from the slicer?

 

Does anyone know what I should be using please?

 

Thank you

1 REPLY 1
lbendlin
Super User
Super User

I want to show a Table visual which shows the total sales for 2024 vs the total sales for 2023

That would be unfair to 2024, no?

 

SAMEPERIODLASTYEAR is part of the solution, but it is not sufficient.  You need to add a cutoff filter when you show YTD.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.