Forum Discussion
Remove Future Dates from Rolling 12 Month Measures
- Anonymous5 years ago
My measure absolutely works the way you want. It's an adaptation of the technique from www.sqlbi.com by Alberto and Marco. It uses a technique known as "the interception of filters" to do the right thing. I have used it in many other projects and it's always worked correctly. I would really be surprised if it didn't do what it's supposed to. It surely does.
And, of course, it's not true what you say: "I dot not have that issue with the 27 until I use your measure." If you take a look at your very first post in this thread... you'll notice that, indeed, you also have a blank row paired with the numer 26,438. It means the blank row either does exist in your data (it might be a blank or an empty text ""), or the model is creating it due to RI problems. There is NO other possibility.
By the way, I'm talking about this measure (just to be sure we're talking about the same thing):
Rolling 12 Month External Hiring Sum = var VeryLastDateWithAnyHires = CALCULATE( MAX( 'Date'[Date] ), 'Date'[DatesWithHires], ALL( 'Date' ) ) var TotalPeriodWithHires = CALCULATETABLE( DISTINCT( 'Date'[Date] ), 'Date'[Date] <= VeryLastDateWithAnyHires ) var EffectiveDates = INTERSECT( TotalPeriodWithHires, DISTINCT( 'Date'[Date] ) ) var MaxEffectiveDate = MAXX( EffectiveDates, 'Date'[Date] ) var Result = CALCULATE( COUNTROWS( 'External Hires' ), DATESINPERIOD( 'Date'[Date], MaxEffectiveDate, -1, YEAR ), KEEPFILTERS( 'Date'[DatesWithHires] ) ) return Result
Hello CatManKuhn
Try this.
Create a calculated column in the date table.
IsFuture =
IF(Dates[Date] > Today(), "Yes", "No")
Apply visual level filter to No.
- CatManKuhn5 years ago
Helper II
Thanks TarunSharma. This method will absolutely work, but I want to utilize this in the measure itself so that I don't have to have users add a visual filter everytime they use the measure.
- Anonymous5 years agoNot applicable
My measure absolutely works the way you want. It's an adaptation of the technique from www.sqlbi.com by Alberto and Marco. It uses a technique known as "the interception of filters" to do the right thing. I have used it in many other projects and it's always worked correctly. I would really be surprised if it didn't do what it's supposed to. It surely does.
And, of course, it's not true what you say: "I dot not have that issue with the 27 until I use your measure." If you take a look at your very first post in this thread... you'll notice that, indeed, you also have a blank row paired with the numer 26,438. It means the blank row either does exist in your data (it might be a blank or an empty text ""), or the model is creating it due to RI problems. There is NO other possibility.
By the way, I'm talking about this measure (just to be sure we're talking about the same thing):
Rolling 12 Month External Hiring Sum = var VeryLastDateWithAnyHires = CALCULATE( MAX( 'Date'[Date] ), 'Date'[DatesWithHires], ALL( 'Date' ) ) var TotalPeriodWithHires = CALCULATETABLE( DISTINCT( 'Date'[Date] ), 'Date'[Date] <= VeryLastDateWithAnyHires ) var EffectiveDates = INTERSECT( TotalPeriodWithHires, DISTINCT( 'Date'[Date] ) ) var MaxEffectiveDate = MAXX( EffectiveDates, 'Date'[Date] ) var Result = CALCULATE( COUNTROWS( 'External Hires' ), DATESINPERIOD( 'Date'[Date], MaxEffectiveDate, -1, YEAR ), KEEPFILTERS( 'Date'[DatesWithHires] ) ) return Result- CatManKuhn5 years ago
Helper II
When I say I do not get that issue I am looking at just my basic count of hires. There is a date associated for each record and each date exists on the date table. I do not understand why this measure would suddenly show 27 that are not associated with a date. If each record has a date that exists on the date table, why would a rolling 12 month show 27 null dates?