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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to filter DAX same period last year column

Hello,

 

I have this table with units and units of the previous period. To be able to filter with this slicer i added to the SPLY metric an ALL() function, because if i do not, the metric doesn't show values when i filter by one specific month as in the screencapture.

 

ticket 1.PNG

My problem now is that i need to show in the table only the values of the month-year filtered in the slicer and the total of only this specific period. Is there any dax function to combine with ALL() in order to display only the selected datetime.

 

The way i calculate Same period last year column is:

 

Units SPLY = CALCULATE (
      SUM ( 'Tabla'[Units Actual] );
      ALL(Tabla[Date]);
      SAMEPERIODLASTYEAR (Tabla[Date].[Date])
)

 

Thank you!

 

 

 

 

 

 

 

 

1 REPLY 1
vivran22
Community Champion
Community Champion

Hello @Anonymous ,

 

Ideally, the slicers will slice visuals and show only relevant dates. It is not clear from your example if you have created a calendar table in your data model. For time intelligence function to work properly, it is recommended to have a calendar table in the data model.

 

I have recreated a sample scenario, and used following measures:

 

Total Orders (SPLY) = 
    CALCULATE(
       [Total Orders],
       SAMEPERIODLASTYEAR(ftCalendar[Date])
    )

Total Orders A(SPLY) = 
    CALCULATE(
       [Total Orders],
       ALL(ftCalendar[Date]),
       SAMEPERIODLASTYEAR(ftCalendar[Date])
    )

 

 

Following is the result:

 

Capture.JPG

As you can see, both the formula is giving me the desired results and the visual is filtering accordingly.

In this, I have created a calendar table and used it in the model.

 

You may refer to the article for adding a calendar table: 

https://www.vivran.in/post/power-bi-time-intelligence-calendar-table

 

 

Cheers!
Vivek

If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)

 

Feel free to email me for any BI needs.

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.