Forum Discussion
Max Month -1
In your case MaxMonthValue calculation for "Max Month -1" subtracts 1 from the maximum year-month number found in the data that meets the condition [UsagesCount] >= 1. This works well in an unfiltered context because it works on the entire dataset.
However, when you apply a filter to a specific month, this changes the dataset that MaxMonthValue operates on, likely resulting in a different maximum year-month number or potentially no suitable data at all after the subtraction. This is especially true if the filtered month is the actual maximum month in your dataset since subtracting one would point to a month that's not included in your filter context
Max Month -1 Usages =
VAR MaxMonthValue =
CALCULATE(
MAX('Date'[Year Month Number]) - 1,
ALL('Date'), // Ignores the filter context for this calculation
'Date'[UsagesCount] >= 1
)
RETURN
CALCULATE(
[Total Kwh],
'Date'[Year Month Number] = MaxMonthValue
)
Thanks for the Quick response,
I'm getting a Function Placeholder is being used Error ?
- AmiraBedh2 years ago
Super User
Can you share your dataset ?
- JamesBurke2 years ago
Helper III
I'm not able to share my dataset unfortunately
- JamesBurke2 years ago
Helper III
Max Month Usages -1 =Var MaxMonthValue =CALCULATE(MAX('Date'[Year Month Number])-1 ,ALL('Date'),FILTER('Date',[UsagesCount] >= 1))RETURNCALCULATE([Total Kwh],'Date'[Year Month Number] = MaxMonthValue)Does not have an error when using the Filter function however returns blank still