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
TheSweeper
Helper I
Helper I

PLZ HLP!!!! Creating calculation for Comparing Same Date This Year versus Last Year

I am trying to do Time Series calculations (whatever that really means) for Same Date compared to Same Date Last Year. If you can kindly help me from  losing more hair I would kindly appreciate your generosity!  

 

Here are the formulas I am using 

 
  • Collections LY by trend date = CALCULATE([Collections Total],SAMEPERIODLASTYEAR(('Calendar'[Date]))) - This is still showing dates until end of year.  I only want it to show data up until this years date last year.  
  • Collections TY by trend date = CALCULATE([Collections Total], FILTER('Calendar', 'Calendar'[Date] < TODAY()))
     
     
    This Year Last Year by Post Date (2).png
    DateCollections TY by trend dateCollections LY by trend date
    11/30/2021 0:00 $34,776.25
    11/28/2021 0:00 $852.91
    11/27/2021 0:00 $31,860.07
    11/26/2021 0:00 $207.88
    11/25/2021 0:00 $52,373.37
    11/24/2021 0:00 $14,278.67
    11/23/2021 0:00 $31,774.04
    11/22/2021 0:00$24,062 
    11/20/2021 0:00 $69,379.20
    11/19/2021 0:00$12,817.15$32,289.16
    11/18/2021 0:00$11,018.94$16,537.48
    11/17/2021 0:00$21,989.74$30,357.17
    11/16/2021 0:00$37,128.55$72,194.82
    11/15/2021 0:00$6,564.91 
    11/13/2021 0:00 $25,637.27
    11/12/2021 0:00$17,404.07$11,558.63
    11/11/2021 0:00$15,845.59$18,377
    11/10/2021 0:00$14,042.51$34,213.14
    11/9/2021 0:00$11,786.98$36,534.50
    11/8/2021 0:00$19,856$0
    11/6/2021 0:00 $35,570.67
    11/5/2021 0:00$17,466.67$19,411.81
    11/4/2021 0:00$30,881.84$15,212.39
    11/3/2021 0:00$13,875.26$32,911.77
    11/2/2021 0:00$7,060.54$5,371.41
    11/1/2021 0:00$13,559.69 

     

    TheSweeper_0-1637693736968.png

     

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@TheSweeper , In the case of the calculation group using tabular editor

 

CALCULATE(selectedmeasure(), FILTER('Calendar', 'Calendar'[Date] < TODAY()))

 

 

Last year

CALCULATE(selectedmeasure(), sameperiodlastyear('Calendar'[Date]), FILTER('Calendar', 'Calendar'[Date] < date(year(TODAY())-1 ,month(Today()) , day(today()))))

 

or

 

CALCULATE(selectedmeasure(), dateadd('Calendar'[Date],-1, year), 'Calendar'[Date] < date(year(TODAY())-1 ,month(Today()) , day(today())) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi  @TheSweeper ,

I created some data:

vyangliumsft_0-1637896327091.png

Here are the steps you can follow:

1. Create a calendar table.

Slice = CALENDARAUTO()

vyangliumsft_1-1637896327092.png

2. Create measure.

Collections LY by trend date =
CALCULATE(SUM('Calendar'[Collections Total]),
FILTER(ALL('Calendar'),'Calendar'[Date]=DATE(YEAR(MAX('Calendar'[Date]))-1,MONTH(MAX('Calendar'[Date])),DAY(MAX('Calendar'[Date])))))
Flag =
IF(MAX('Calendar'[Date])>=MIN('Slice'[Date])&&MAX('Calendar'[Date])<=MAX('Slice'[Date]),1,0)

3. Place Measure[Flag] in the filter, select is=1, and apply filter.

vyangliumsft_2-1637896327094.png

4. Result:

vyangliumsft_3-1637896327096.png

 

Best Regards,

Liu Yang

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  @TheSweeper ,

I created some data:

vyangliumsft_0-1637896327091.png

Here are the steps you can follow:

1. Create a calendar table.

Slice = CALENDARAUTO()

vyangliumsft_1-1637896327092.png

2. Create measure.

Collections LY by trend date =
CALCULATE(SUM('Calendar'[Collections Total]),
FILTER(ALL('Calendar'),'Calendar'[Date]=DATE(YEAR(MAX('Calendar'[Date]))-1,MONTH(MAX('Calendar'[Date])),DAY(MAX('Calendar'[Date])))))
Flag =
IF(MAX('Calendar'[Date])>=MIN('Slice'[Date])&&MAX('Calendar'[Date])<=MAX('Slice'[Date]),1,0)

3. Place Measure[Flag] in the filter, select is=1, and apply filter.

vyangliumsft_2-1637896327094.png

4. Result:

vyangliumsft_3-1637896327096.png

 

Best Regards,

Liu Yang

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

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

Collections LY by trend date = if(min('Calendar'[Date])<=TODAY(),CALCULATE([Collections Total],SAMEPERIODLASTYEAR('Calendar'[Date])),blank())


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@TheSweeper , In the case of the calculation group using tabular editor

 

CALCULATE(selectedmeasure(), FILTER('Calendar', 'Calendar'[Date] < TODAY()))

 

 

Last year

CALCULATE(selectedmeasure(), sameperiodlastyear('Calendar'[Date]), FILTER('Calendar', 'Calendar'[Date] < date(year(TODAY())-1 ,month(Today()) , day(today()))))

 

or

 

CALCULATE(selectedmeasure(), dateadd('Calendar'[Date],-1, year), 'Calendar'[Date] < date(year(TODAY())-1 ,month(Today()) , day(today())) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors