Forum Discussion
Max Month usages
Hi JamesBurke ,
The core of the issue seems to be related to how the filter context is applied in your DAX formula for "Max Month Usages -1".
When you filter down to a specific month, the function's filter context is changed, which affects how the function computes the maximum value of 'Date'[Year Month Number].
Please try:
Max Month Usages -1 =
VAR CurrentMaxMonthValue =
CALCULATE(
MAX('Date'[Year Month Number]),
ALLSELECTED('Date')
)
VAR MaxMonthValue =
CALCULATE(
MAX('Date'[Year Month Number]) - 1,
FILTER(
ALL('Date'),
'Date'[Year Month Number] < CurrentMaxMonthValue
&& [UsagesCount] >= 1
)
)
RETURN
CALCULATE(
[Total Kwh],
'Date'[Year Month Number] = MaxMonthValue
)
I would be grateful if you could provide me with sample data for testing, please remove any sensitive data in advance.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi Anonymous ,
Thanks for this ! unfortunately the issue still remains.
Max Usages -1 Example Data.pbix
Attached is some example data without the sensetive data, It uses my old measurments as well as the one you suggested.
Thanks, James