Forum Discussion
Running Total Help
- 4 years ago
Hi All
I believe I have found a nice solution to my query.
I came across this great article https://www.sqlbi.com/articles/hiding-future-dates-for-calculations-in-dax/
So I followed the 2 methods described.
I created a calculated column in the Dates table:
DatesWithProdVals = 'Dates'[CurDate] <= MAX ( DailyProd[pdate] )This column had a value of True up to and including the maximum production date.
I then created the following measure:
Sales YTD v1 = CALCULATE ( [CY Daily Prod Value], CALCULATETABLE ( DATESYTD ( Dates[CurDate],"30/06" ), Dates[DatesWithProdVals] = TRUE ) )This measure gave me exactly what i wished.
I also followed the described procedure without creating a calculated column:
Sales YTD v2 = VAR LastDayAvailable = CALCULATE ( MAX ( DailyProd[pdate] ), ALL ( DailyProd ) ) VAR FirstDayInSelection = MIN ( 'Dates'[CurDate] ) VAR ShowData = (FirstDayInSelection <= LastDayAvailable) RETURN IF ( ShowData, CALCULATE ( [CY Daily Prod Value], DATESYTD ( 'Dates'[CurDate],"30/06" ) ) )This again produced the running ytd values for only July - December. However this measure does not display a total value (see table below). I don't know why.
YTD Table
Thanks everyone for you help.
Until the next time 😉
Jake
I suspect your inner measure is overriding the filters you are trying to create for the YTD calculation. Do you get the same result if you use that measure directly? What is the expression for your [Daily Prod Value] measure? Does it work if you use that in place of the [CV Daily Prod Value] measure in your RT expression?
Pat