Forum Discussion

Dan_B's avatar
Dan_B
New Member
6 years ago
Solved

Calculate the difference between quantities per month over two years

I am trying to do a simple calculation that is not being very easy to do.   I am trying to find the difference in quantity for each month in 2019 and 2020.    I split out the creation date into Month...
  • lbendlin's avatar
    6 years ago

    Not proud of this one but here goes:

     

    Create two measures

    2019 =
    var m = SELECTEDVALUE('Values'[Month])
    return calculate(sum('Values'[Value]),'Values'[Year]=2019,'Values'[Month]=m)
     
    2020 =
    var m = SELECTEDVALUE('Values'[Month])
    return calculate(sum('Values'[Value]),'Values'[Year]=2020,'Values'[Month]=m)
     
    Then create a matrix visual with the Month as rows. NOTHING as columns, and the two measures as values.
     
    Lastly create another measure
    diff = [2020]-[2019]
     
    and also add to the values area.
     
    May need cleanup for the scenario where 2020 values are blank - not sure what you want to do in such a case.