Forum Discussion
Anonymous
8 years agoNot applicable
Delta Calculation strange results
Hi there, I have two tables in my SQL Server 2017 The CurrentMemberYr produce the expected results but The CurrentMemberBr with the slicer did not as you can see in the attachment How do I fix ...
- 8 years ago
Hello Anonymous
Can you please try the following query and let me know if it works?
SELECT
Branch,
Years,
CurrentMembers, CASE
WHEN Branch != LAG(Branch, 1) OVER (ORDER BY Branch, Years) THEN NULL ELSE CurrentMembers - LAG(CurrentMembers,1) OVER (ORDER BY Branch, Years)
END AS Delta FROM CurrentMemberBr ORDER BY Branch, Years
DanielV91
8 years agoFrequent Visitor
Hello Anonymous
Can you please try the following query and let me know if it works?
SELECT
Branch,
Years,
CurrentMembers, CASE
WHEN Branch != LAG(Branch, 1) OVER (ORDER BY Branch, Years) THEN NULL ELSE CurrentMembers - LAG(CurrentMembers,1) OVER (ORDER BY Branch, Years)
END AS Delta FROM CurrentMemberBr ORDER BY Branch, Years
- Anonymous8 years agoNot applicable
Daniel,
Yes it works
Thank you so much
Oded Dror