Forum Discussion
Rolling 12m for each date
- 9 years ago
Why do you have that additional reference to the Date extension? The formula should look like this:
test 12m = CALCULATE ( SUM ( Sales[SalesAmount] ); DATESINPERIOD ( DateTable[Date]; CALCULATE ( MAX ( DateTable[Date] ) ); -1; YEAR ) )Notice the missing .[Date] in the first parameter of DATESINPERIOD (DateTable[Date]).
The extension created by Power BI contains the full year. My advice is always the same with auto date/time: disable it, learn time intelligence and forget about its existence :)
Anyway, removing that reference should fix the problem although a date table ending in August 26 is not a best practice, the best would be to protect your code using an IF statement that blanks the measure. With that said, in your special case, you can live with an incomplete date table.
Have fun with DAX!
Alberto Ferrari
http://www.sqlbi.comAlberto
Why do you have that additional reference to the Date extension? The formula should look like this:
test 12m =
CALCULATE (
SUM ( Sales[SalesAmount] );
DATESINPERIOD (
DateTable[Date];
CALCULATE ( MAX ( DateTable[Date] ) );
-1;
YEAR
)
)Notice the missing .[Date] in the first parameter of DATESINPERIOD (DateTable[Date]).
The extension created by Power BI contains the full year. My advice is always the same with auto date/time: disable it, learn time intelligence and forget about its existence :)
Anyway, removing that reference should fix the problem although a date table ending in August 26 is not a best practice, the best would be to protect your code using an IF statement that blanks the measure. With that said, in your special case, you can live with an incomplete date table.
Have fun with DAX!
Alberto Ferrari
http://www.sqlbi.com
Alberto
Hi!
An old thread but has something changed or would you be able to explain the below.
but why I get 2018-12-01 from the below and not 2018-11-20:
First Date in the Period for DatesInPeriod =
First Date in the Period for DatesInPeriod =