• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

YTD Calc is Erroring on Me

I am having issues with an interesting calculation. The fun part is that our reporting for current month has iterations (Day 4, Day 5, etc) before becoming "Final." So, I need to display a YTD calc for the ["Final" for the previous months + the Selected Iteration for the current month]. Below is my formula with variables. I get an error when I attempt to add two CALCULATE functions together at the end of my SWITCH. Please help.


z_YTD Actual =
VAR SelectedMonth = SELECTEDVALUE('Trend'[Month])
VAR SelectedYear = SELECTEDVALUE('Trend'[Fiscal Year])
VAR FirstDay = DATE(SelectedYear,1,1)
VAR LastDay = LOOKUPVALUE('Calendar'[Date],'Calendar'[Fiscal Year],SelectedYear,'Calendar'[Month], SelectedMonth)
VAR SelectedPeriod = LOOKUPVALUE('Calendar'[Period],'Calendar'[Month],SelectedMonth)
VAR SelectedLineDesc = SELECTEDVALUE('PL Format'[Line Description])
VAR SelectedVarClass = SELECTEDVALUE('Trend'[Variance Class])
VAR LastDay1 = LOOKUPVALUE('Calendar'[Date],'Calendar'[Fiscal Year],SelectedYear,'Calendar'[Month],FORMAT(EOMONTH(LastDay,-1), "mmm"))
VAR SelectedIteration = SELECTEDVALUE('Trend'[Iteration])


RETURN
SWITCH(TRUE(),
SelectedIteration = "Final",
CALCULATE(
[MTD Actual],
DATESBETWEEN('Calendar'[Date], FirstDay, LastDay),'Trend'[Fiscal Year] = SelectedYear),
CALCULATE(
[MTD Actual],
DATESBETWEEN('Calendar'[Date], FirstDay, LastDay1),'Trend'[Fiscal Year] = SelectedYear,'Trend'[Iteration] = "Final"))
 
Back
Top