Forum Discussion

Lancelot's avatar
Lancelot
Frequent Visitor
3 years ago
Solved

YTD Total

Hi All

 

I need to get a year to date total not in an ordinary way:

 

YTD Profit =
var _numMonths = SELECTEDVALUE('Date'[Date].[MonthNo])
RETURN
CALCULATE([Profit After Tax]
                      ,VALUE(SELECTEDVALUE('Date'[Date].[Year])) = VALUE(YEAR('Trial Balance'[Period Date]))
                      ,SELECTEDVALUE('Date'[Date].[Month]) <= 'Trial Balance'[Month]
                      ,DATEADD('Date'[Date],-8,MONTH)
                    )
 
Based on the Month selected, I would like to know the month number and run the dateadd iteration that many times whhile I sum up the values.
 
Any suggestions will greatly be appreciated.