Forum Discussion
Measure for values in a date range
- 1 year ago
RichOB , Try using
Instances_2023 =
CALCULATE(
SUM('Table'[Instances]),
YEAR('Table'[Date]) = 2023
)Instances_2024 =
CALCULATE(
SUM('Table'[Instances]),
YEAR('Table'[Date]) = 2024
) - 1 year ago
RichOB , Try using
2023_Instances =
CALCULATE(
COUNT('Table'[Instances]),
FILTER(
'Table',
'Table'[Date] >= DATE(2023, 1, 4) && 'Table'[Date] <= DATE(2023, 3, 31)
)
) - Anonymous1 year ago
Hi RichOB
Thank you very much bhanu_gautam for your prompt reply.
I tested your measure and bhanu_gautam's measure separately and both give correct results. If your code does not work, check that the data type of the date is correct.
If there are any potential filters applied to your report that may also affect the calculation. You may consider using the ALL function to ignore these filters.
Filter ALL 2023_Instances = CALCULATE( COUNT('Table'[Instances]), FILTER( ALL('Table'), 'Table'[Date] >= DATE(2023, 1, 4) && 'Table'[Date] <= DATE(2024, 3, 31) ) )Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi RichOB
Thank you very much bhanu_gautam for your prompt reply.
I tested your measure and bhanu_gautam's measure separately and both give correct results. If your code does not work, check that the data type of the date is correct.
If there are any potential filters applied to your report that may also affect the calculation. You may consider using the ALL function to ignore these filters.
Filter ALL 2023_Instances =
CALCULATE(
COUNT('Table'[Instances]),
FILTER(
ALL('Table'),
'Table'[Date] >= DATE(2023, 1, 4) && 'Table'[Date] <= DATE(2024, 3, 31)
)
)
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.