Forum Discussion

GeraSanz11's avatar
GeraSanz11
Frequent Visitor
9 years ago
Solved

Compare data using a given filter

Hi there!   Im having some trouble with comparing information. I have a data set like this (It's only annual information no months nor days)   Year  | Amount 2015 |  123 2015 |  421 2014 |  32...
  • TomMartens's avatar
    9 years ago

    Hey,

     

    one possible solution could be to create a measure that calculates the amount of previous year like so:

    amount PY = 
    IF(HASONEFILTER('Table1'[Year]),
     var py = values('Table1'[Year]) -1
     return
     CALCULATE(SUM('Table1'[Amount]),
      'Table1'[Year] = py
     ),
     BLANK()
    )

    Now you can use both measures in any visualization, if more than one year is selected or NONE, the measure returns a BLANK() / NULL value  

     

    Hope this is what you are looking for