Forum Discussion

MichaelG_NAC's avatar
MichaelG_NAC
Frequent Visitor
3 years ago
Solved

Comparing value between years based on another column

Hello 

I am looking to compare Values between diffrent years 

YearUniqueValue

1

A5
1B10
2A15
3C16
2B20


so at the end im looking to have a subtraction from the highest year - the lowest year based on the Unique 

 

UniqueValue
A10 (15-5)
B10 (20-10)
C16

 

Would this be possible or would another method be needed

  • Hi,

     

    try this:

     

    Measure 4 = var _max = CALCULATE(max('Table (3)'[Value]),ALLEXCEPT('Table (3)','Table (3)'[Unique]))

    var _min = CALCULATE(min('Table (3)'[Value]),ALLEXCEPT('Table (3)','Table (3)'[Unique]))

    return

     if(COUNT('Table (3)'[Unique])=1,_max,_max - _min)
     

     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

1 Reply

  • DOLEARY85's avatar
    DOLEARY85
    Resident Rockstar

    Hi,

     

    try this:

     

    Measure 4 = var _max = CALCULATE(max('Table (3)'[Value]),ALLEXCEPT('Table (3)','Table (3)'[Unique]))

    var _min = CALCULATE(min('Table (3)'[Value]),ALLEXCEPT('Table (3)','Table (3)'[Unique]))

    return

     if(COUNT('Table (3)'[Unique])=1,_max,_max - _min)
     

     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍