Forum Discussion
Anonymous
4 years agoNot applicable
Need help with YTD Calculated Column per record field
Hello Team, I am trying to create a Calculated column that calculates the YTD values per cora_acc_code-accountnumber basis. There are 165 distinct accountnumber records for which I am calculating...
- 4 years ago
Hey Anonymous ,
the following measure should do it. I added some explanations what the mesaure is doing:
YTD Measure = -- save account and date of current row in a variable VAR vAccountRow = myTable[cora_acc_code-accountnumber] VAR vDate = myTable[Period Date] -- calculate the sum and filter table to off rows of -- the current year that are smaller or equal to the row date VAR vResult = CALCULATE ( SUM ( myTable[Sum of Value] ), ALL ( myTable ), myTable[cora_acc_code-accountnumber] = vAccountRow && YEAR ( myTable[Period Date] ) = YEAR ( vDate ) && myTable[Period Date] <= vDate ) RETURN vResultIf you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
selimovd
4 years agoMost Valuable Professional
Hey Anonymous ,
the following measure should do it. I added some explanations what the mesaure is doing:
YTD Measure =
-- save account and date of current row in a variable
VAR vAccountRow = myTable[cora_acc_code-accountnumber]
VAR vDate = myTable[Period Date]
-- calculate the sum and filter table to off rows of
-- the current year that are smaller or equal to the row date
VAR vResult =
CALCULATE (
SUM ( myTable[Sum of Value] ),
ALL ( myTable ),
myTable[cora_acc_code-accountnumber] = vAccountRow
&& YEAR ( myTable[Period Date] ) = YEAR ( vDate )
&& myTable[Period Date] <= vDate
)
RETURN
vResult
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
Anonymous
4 years agoNot applicable
Hey Denis,
This is perfect! I got it to work finally. Thank you so much.
Regards!