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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PoPQ
Frequent Visitor

Compare values to same month in specific year

I'm interested in creating a measure to compare daily values aggregated to the month with the same month in 2019 as a % difference. For instance, I'd like to compare the sum of December 2021 'thruput' with the same value for December 2019, July 2020 vs. July 2019, etc. I'm not sure I can do this with a simple samperiodlastyear calculation because I always want the comparison year to be fixed at 2019. Data can be found here.

1 ACCEPTED SOLUTION

Hi @PoPQ ,

 

Please try the following formula:

 

Measure = 
CALCULATE (
    SUM ( 'TSA_thruput xlsx - Sheet1'[Thruput] ),
    FILTER (
        ALL ( 'TSA_thruput xlsx - Sheet1' ),
        'TSA_thruput xlsx - Sheet1'[Date].[Month]
            = MAX ( 'TSA_thruput xlsx - Sheet1'[Date].[Month] )
            && 'TSA_thruput xlsx - Sheet1'[Date].[Year] = 2019
    )
)

vkkfmsft_0-1644307633665.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

7 REPLIES 7
mh2587
Super User
Super User

Measure 1 2020= calculate(sum[value],DATEADD(DateTime[DateKey],-1,year)
Measure 2 2021= calculate(sum[value],DATEADD(DateTime[DateKey],-2,year)
Measure 3 2022= calculate(sum[value],DATEADD(DateTime[DateKey],-3,year)


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



PoPQ
Frequent Visitor

I'm hoping to solve this as single measure so I can display it as a single trendline over the span of three years.

Hi @PoPQ ,

 

Please try the following formula:

 

Measure = 
CALCULATE (
    SUM ( 'TSA_thruput xlsx - Sheet1'[Thruput] ),
    FILTER (
        ALL ( 'TSA_thruput xlsx - Sheet1' ),
        'TSA_thruput xlsx - Sheet1'[Date].[Month]
            = MAX ( 'TSA_thruput xlsx - Sheet1'[Date].[Month] )
            && 'TSA_thruput xlsx - Sheet1'[Date].[Year] = 2019
    )
)

vkkfmsft_0-1644307633665.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks! Is there a reason this solution works with the given single-query dataset, but when I include a date table in the data model, the specified .[Month] and .[Year] hierarchies go unrecognized? It throws an error that says: "Column reference to 'Date' in table 'Thruput' cannot be used with a variation 'Month' because it does not have any."

Hi @PoPQ ,

 

There are many reasons why the date hierarchy disappears. You can replace Sheet1'[Date].[Month] and Sheet1'[Date].[Year] with Month( Sheet1'[Date] ) and Year( Sheet1'[Date] ), or use your own created month and year columns, which does not affect the final result.

 

Best Regards,
Winniz

mh2587
Super User
Super User

= calculate(sum[value],DATEADD(DateTime[DateKey],-2,year)


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



PoPQ
Frequent Visitor

thanks @mh2587 for the quick reply. that almost works but it is relative, where I want the comparison year to be 2019 regardless of whether I'm comparing a 2020, 2021 or 2022 month value to it.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors