Forum Discussion

ccakjcrx's avatar
ccakjcrx
Resolver I
8 years ago
Solved

Measure: Subtracting prior value in same column

Hello!   Although it has proven difficult for me, I have what seems to be a simple problem. I want to create a measure to subtract the prior value in the same column from the current row. In the sc...
  • Interkoubess's avatar
    Interkoubess
    8 years ago

    Hi ccakjcrx,

     

    As proposed by Greg_Deckler you can create a calculated column ( I called it Difference) as below:

     

    Difference = Sheet1[value]-CALCULATE(MAX(Sheet1[value]),FILTER(Sheet1,Sheet1[date]<EARLIER(Sheet1[date])))

    You can improve it for the first line when it is blank like this:

    Difference = if(ISBLANK(CALCULATE(MAX(Sheet1[value]),FILTER(Sheet1,Sheet1[date]<EARLIER(Sheet1[date])))),BLANK(),Sheet1[value]-CALCULATE(MAX(Sheet1[value]),FILTER(Sheet1,Sheet1[date]<EARLIER(Sheet1[date]))))

    Let us know it does not work...

     

    Ninter