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
DavidEg
Frequent Visitor

SAMEPERIODLASTYEAR with previous date filter

Hi,

 

I have a table tickets, with two dates. Opening Date and solution Date. I relate them through a calendar table.

 

N_TicketsOpening = CALCULATE (COUNT (CCBI_vwTickets [TicketId]), CCBI_vwTickets [OpeningDate])

 

And I need a measure that counts the tickets from the same previous period.

 

I tried

N_TicketsOpening_LY = CALCULATE (COUNT (CCBI_vwTickets [TicketId]), SAMEPERIODLASTYEAR (CCBI_vwTickets [OpeningDate]))

 

but it doesn't work, it doesn't show data.

 

I put a page filter that selects the last 12 calendar months.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DavidEg 

My Sample:

1.png

I add YearMonth into Page filter and select 202101 and 202112.

Please try my measure:

N_TicketsOpening_LY = 
VAR _CurYear = YEAR(MAX(CCBI_vwTickets[OpeningDate]))
Return
CALCULATE(COUNT(CCBI_vwTickets[TicketId]),FILTER(ALL(CCBI_vwTickets),YEAR(CCBI_vwTickets[OpeningDate])=_CurYear-1))

Result is as below.

2.png

If this reply still couldn't help you solve your problem, please show me a sample like what you are dealing with by your Onedrive for Business.

This will make it easier for me to understand your requirement.

 

Best Regards,

Rico Zhou

 

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @DavidEg 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

Anonymous
Not applicable

Hi @DavidEg 

My Sample:

1.png

I add YearMonth into Page filter and select 202101 and 202112.

Please try my measure:

N_TicketsOpening_LY = 
VAR _CurYear = YEAR(MAX(CCBI_vwTickets[OpeningDate]))
Return
CALCULATE(COUNT(CCBI_vwTickets[TicketId]),FILTER(ALL(CCBI_vwTickets),YEAR(CCBI_vwTickets[OpeningDate])=_CurYear-1))

Result is as below.

2.png

If this reply still couldn't help you solve your problem, please show me a sample like what you are dealing with by your Onedrive for Business.

This will make it easier for me to understand your requirement.

 

Best Regards,

Rico Zhou

 

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

Greg_Deckler
Community Champion
Community Champion

@DavidEg - If you are using a page filter, then you will not be able to get those rows back via DAX using ALL or ALLEXCEPT, etc. Page filters pre-filter the rows available to DAX calculations.

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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