I have three column one is Id(ID is same) 2nd col is amount and third is date, I want difference between two rows(amount)
1
votes
adding your sample data and explaining a bit about your desired result will be helpful to provide some ideas
– AnkUser
Post some sample data and your desired results
– StelioK
Column1 101 , 101 , 101 Clumn2 512 , 510, 610, 480 now i want to subtract these column 2 values like 510-580=70 and 580-610=30
– Muhammad Adil
2 Answers
3
votes
As you want to have the previous value of the date where the ID is equal, you can use the following:
Add a column,
Column4 =
var baseFilter = FILTER(DiffRows;DiffRows[Column1] = EARLIER(DiffRows[Column1]))
var selectDate = CALCULATE(LASTDATE(DiffRows[Column3]);baseFilter;
FILTER(baseFilter; DiffRows[Column3] < EARLIER(DiffRows[Column3])))
return
DiffRows[Column2] - CALCULATE(sum(DiffRows[Column2]);baseFilter;
FILTER(baseFilter; DiffRows[Column3] =selectDate))
First I create a basefilter to ensure the IDs are same. Next I select the date whcih is the previousdate within the set of same ids Last I use this date, to filter the correct value out of the rows.
End result:
-1
votes
agradecería mucho si me pueden ayudar, tengo el mismo caso, pero en la columna 3 de fecha tambien tengo horas, y al aplicar la fórmula me da un error:
"A date column containing duplicate dates was specified in the call to the 'LASTDATE' function. This is not supported"
Agradecería vuestra ayuda. Un saludo.