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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
matdub40
Helper III
Helper III

How to calculate the difference between two values in different years?

I have a date table that contains these columns:

Capture.JPG

 

 

I use a "Euro Gross Amount" measure in a matrix on Power BI:

 

Capture.JPG

 

I would like to calculate the difference on the Euro Gross between the different years in percentage, I used this formula but it comes out as an "enexpected tuple" error :

 

DIFF% = DIVIDE(([Euro Gross Amount] - CALCULATE ([Euro Gross Amount], SAMEPERIODLASTYEAR('date'[date])), CALCULATE ([Euro Gross Amount], SAMEPERIODLASTYEAR('date'[date]), 0)

 

Where does my error come from? Is there a better way to calculate this difference?

1 ACCEPTED SOLUTION
PC2790
Community Champion
Community Champion

Try this:

DIFF =
DIVIDE (
    [Euro Gross Amount]
        CALCULATE ( [Euro Gross Amount], SAMEPERIODLASTYEAR ( 'date'[date] ) ),
    CALCULATE ( [Euro Gross Amount], SAMEPERIODLASTYEAR ( 'date'[date] ) ),
    0
)
 
And convert this measure to a percentage in Measure Tools section

View solution in original post

3 REPLIES 3
PC2790
Community Champion
Community Champion

Try this:

DIFF =
DIVIDE (
    [Euro Gross Amount]
        CALCULATE ( [Euro Gross Amount], SAMEPERIODLASTYEAR ( 'date'[date] ) ),
    CALCULATE ( [Euro Gross Amount], SAMEPERIODLASTYEAR ( 'date'[date] ) ),
    0
)
 
And convert this measure to a percentage in Measure Tools section

Hello @PC2790 ,

 

Since this morning I have an error on my measurement "Evo%" which tells me

 

"MdxScript(Prod_WS_RCE_Order_SKU) (145, 44) Calculation error in measure 'dwh_d_order_sku'[Evo %]: The 'SAMEPERIODLASTYEAR' function expects a contiguous selection when the date column comes from a table on side 1 of a bidirectional relationship. "

 

Is this normal or should I change something?

Thanks for your answer @PC2790 , it solved my problem!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.