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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

COMPARE Value differences between 2 columns by DATE

Hi the community, 

 

I'm making progress in DAX but i'm still stucked on begginer issues. 

 

Imagine i have this kind of data : 

 

VendorPartConditionQuantityNet Order Year
Jack aero1123040Scrap510002018
Jack aero1123040Scrap820002019
Jack aero1132050Overhaul215002018
Jack aero1132050Overhaul630002019
      

 

I would like to know how to calculate the difference in term of quantity and net order between 2018-2019 by part and by Vendor. 

 

By example a column or a formula which gave me like for the part 1123040 -3 and 1000$

 

Thank you so much in advance for any help !! 

Best

2 REPLIES 2
Anonymous
Not applicable

You can start by creating measures to calculate the amounts in the periods you want to compare. The years in this example could be fetched from selections in slicers, current year or something else in the below formulas.

QuantityCurrentYear =
VAR CurrentYear = 2019
RETURN
    CALCULATE (
        SUM ( Orders[Quantity] );
        KEEPFILTERS ( Orders[Year] = CurrentYear )
    )
QuantityPreviousYear =
VAR PrevYear = 2018
RETURN
    CALCULATE (
        SUM ( Orders[Quantity] );
        KEEPFILTERS ( Orders[Year] = PrevYear )
    )

 

Then create the measure that groups on vendor and part and calculates the difference:

QuantityDifference =
SUMX (
    SUMMARIZE ( Orders; 'Orders'[Vendor]; Orders[Part] );
    [QuantityCurrentYear] - [QuantityPreviousYear]
)

 

(if you use english settings, replace ; with ,)

 

Best Regards // Ulf

Anonymous
Not applicable

Honnestly this is great ! thank you for this first step. 

 

But the only problem is that i have is the following one : 

VendorPart Order QuantityOrder DifferenceYear
Jack aero1120005-52018
Jack aero112000772019
BUSAIR aviation15000010-102018
BUSAIR aviation15000020202019
total 42122019

 

But what i would like to see is where i have the bigger difference by part number. Or, in this case i just see for the total or if i'm selectionning one part with a slicer. 

On this point, i would like a coulum, like "2019 difference", where you could see for each part easily the difference before the previous year (2018). 

 

One row out 2 will show a data... something like that 

Part2019 difference
1120002
1500010
total12


thanks again for your help ! 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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