Forum Discussion
SAMEPERIOD Lastyear
- 6 years ago
Hi sure19
you can try something like this:
var _maxDate = CALCULATE(max('Table'[Date]),ALL('Table')) return date(YEAR(_maxDate),MONTH(_maxDate)-12,1)where Table[Date] should be the date column in your data table.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too. - 6 years ago
You should probably use the filter-function, and you are also missing the criteria for the date. Try something like this:
MMBFQUAYYTD19 = VAR _MXDATE = CALCULATE ( MAX ( TP_ENG_METRICS[MONTHDATE] ), ALL ( 'TP_ENG_METRICS' ) ) RETURN CALCULATE ( AVERAGE ( TP_ENG_KPI[KPI_VALUE] ), FILTER ( 'TP_ENG_KPI', 'TP_ENG_KPI'[KPI] IN { "MMBF FUN" } && TP_ENG_KPI[MonthDate] >= DATE ( YEAR ( _MXDATE ), MONTH ( _MXDATE ) - 12, 1 ) ) )
Hi sure19
you can try something like this:
var _maxDate = CALCULATE(max('Table'[Date]),ALL('Table'))
return
date(YEAR(_maxDate),MONTH(_maxDate)-12,1)
where Table[Date] should be the date column in your data table.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
- sure196 years ago
Helper II
Hi sturlaws when i use this in my formula, i get some error. it works independently as a measure though. Here below it gives some error,
MMBFQUAYYTD19 =VAR _MXDATE =CALCULATE ( MAX ( TP_ENG_METRICS[MONTHDATE] ), ALL ( 'TP_ENG_METRICS' ) )RETURNCALCULATE(AVERAGE(TP_ENG_KPI[KPI_VALUE]),'TP_ENG_KPI'[KPI] IN { "MMBF FUN" },DATE ( YEAR ( _MXDATE ), MONTH ( _MXDATE ) - 12, 1 ))the error is "The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column.
- sturlaws6 years ago
Resident Rockstar
You should probably use the filter-function, and you are also missing the criteria for the date. Try something like this:
MMBFQUAYYTD19 = VAR _MXDATE = CALCULATE ( MAX ( TP_ENG_METRICS[MONTHDATE] ), ALL ( 'TP_ENG_METRICS' ) ) RETURN CALCULATE ( AVERAGE ( TP_ENG_KPI[KPI_VALUE] ), FILTER ( 'TP_ENG_KPI', 'TP_ENG_KPI'[KPI] IN { "MMBF FUN" } && TP_ENG_KPI[MonthDate] >= DATE ( YEAR ( _MXDATE ), MONTH ( _MXDATE ) - 12, 1 ) ) )