Forum Discussion
subtracting previous row value from current row dynamically in Table visual
- Anonymous2 years ago
Hi aatish178
First, we need to ensure we have a measure that calculates the total count of StudentID for each FY.
Total Students = COUNT('Table'[StudentID])Next, we'll create a measure that calculates the difference in the count of StudentID between each FY and the previous FY.
Difference = VAR CurrentFY = MAX('Table'[FY]) VAR PreviousFY = CurrentFY - 1 VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY) VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY) RETURN CurrentFYCount - PreviousFYCount% = VAR CurrentFY = MAX('Table'[FY]) VAR PreviousFY = CurrentFY - 1 VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY) VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY) RETURN (CurrentFYCount - PreviousFYCount)/PreviousFYCountThis is the result you want:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi aatish178
First, we need to ensure we have a measure that calculates the total count of StudentID for each FY.
Total Students = COUNT('Table'[StudentID])
Next, we'll create a measure that calculates the difference in the count of StudentID between each FY and the previous FY.
Difference =
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN CurrentFYCount - PreviousFYCount% =
VAR CurrentFY = MAX('Table'[FY])
VAR PreviousFY = CurrentFY - 1
VAR CurrentFYCount = CALCULATE([Total Students], 'Table'[FY] = CurrentFY)
VAR PreviousFYCount = CALCULATE([Total Students], 'Table'[FY] = PreviousFY)
RETURN (CurrentFYCount - PreviousFYCount)/PreviousFYCount
This is the result you want:
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Jayleny,
Thanks the solution is working as expected. The only change I did is I used Right(Max(FY),2) to fetch only number for further subtraction and it worked.
Thanks once again.