Forum Discussion

roundbunny's avatar
roundbunny
Frequent Visitor
2 years ago
Solved

calculating differences between rows when using 4 slicers

Hi everyone,

I'd like to calculate differences for PRICE when using multiple slicers.   I would like to compare PRICE within the same PRODUCT/STATE/YEAR/SIZE.  (In my dataset, I have one unique row for every combination of PRODUCT/STATE/YEAR/SIZE). 

 

In the example below, I would want to calculate the difference in price for the blue rows, and do the same thing for the green rows. 

(e.g. the difference for blue rows would be 5-3=2.  The difference for green rows would be 6-5=1.)


I have 4 slicers for PRODUCT, STATE, YEAR, SIZE. 

PRODUCT STATEYEARSIZEPRICE
AppleCA2001S3
AppleGA2002M4
AppleCA2003S5
BananaFI2002M5
BananaFI2003M6
BananaFI2004M7
CherryCA2002L1
CherryFI2004M5

 

Thank you so much in advance for your help!!! 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi roundbunny ,

    The Table data is shown below:

    Please follow these steps:
    1. Use the following DAX expression to create a measure named ‘Price difference’

    Price difference = 
    VAR _a = MIN('Table'[PRICE])
    VAR _b = MAX('Table'[PRICE])
    RETURN _b - _a
    

    2. Fianl output

     

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi roundbunny ,

    The Table data is shown below:

    Please follow these steps:
    1. Use the following DAX expression to create a measure named ‘Price difference’

    Price difference = 
    VAR _a = MIN('Table'[PRICE])
    VAR _b = MAX('Table'[PRICE])
    RETURN _b - _a
    

    2. Fianl output

     

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