Is there anything wrong with this calculation?

((case when Date = '2023-03-01' then sum (test1) end ) - (case when Date='2022-03-01' then sum(test2)end)) / (case when Date='2022-03-01' then sum(test2)end)

Trying to calculate the %chg between two points in the dataset

Tagged:

Best Answer

  • MichelleH
    MichelleH Coach
    Answer ✓

    @domoexpert Try putting the SUMs outside of the case statements like this:

    (sum(case when Date = '2023-03-01' then `test1` end ) - sum(case when Date='2022-03-01' then `test2` end)) / sum(case when Date='2022-03-01' then `test2` end)

Answers

  • MichelleH
    MichelleH Coach
    Answer ✓

    @domoexpert Try putting the SUMs outside of the case statements like this:

    (sum(case when Date = '2023-03-01' then `test1` end ) - sum(case when Date='2022-03-01' then `test2` end)) / sum(case when Date='2022-03-01' then `test2` end)