Forum Discussion
Measure for a total count by month
- 1 year ago
Hey there!
You'll need a DAX measure or query that counts the dogs who have overlapping dates within each month of 2024.
You can create a measure like:
ActiveDogs =
COUNTROWS(
FILTER(
Dogs,
(Dogs[Start_Date] <= MAX(Calendar[Date]) && Dogs[End_Date] >= MIN(Calendar[Date]))
)
)This counts the number of dogs whose start and end dates overlap with the selected month.
for you second question:
If you have a Start_Date and End_Date field and you're using a Calendar table, applying a Year and Month filter might not yield correct results. A common solution is to use a DAX measure that explicitly checks if the date range is between the Start_Date and End_Date.
Here’s an approach to work with the date filter correctly:
ActiveDogsPerMonth =
CALCULATE(
[ActiveDogs],
FILTER(
Calendar,
Calendar[Date] >= MIN(Dogs[Start_Date]) &&
Calendar[Date] <= MAX(Dogs[End_Date])
)
)Hope this helps!
😁😁
Hey there!
You'll need a DAX measure or query that counts the dogs who have overlapping dates within each month of 2024.
You can create a measure like:
ActiveDogs =
COUNTROWS(
FILTER(
Dogs,
(Dogs[Start_Date] <= MAX(Calendar[Date]) && Dogs[End_Date] >= MIN(Calendar[Date]))
)
)
This counts the number of dogs whose start and end dates overlap with the selected month.
for you second question:
If you have a Start_Date and End_Date field and you're using a Calendar table, applying a Year and Month filter might not yield correct results. A common solution is to use a DAX measure that explicitly checks if the date range is between the Start_Date and End_Date.
Here’s an approach to work with the date filter correctly:
ActiveDogsPerMonth =
CALCULATE(
[ActiveDogs],
FILTER(
Calendar,
Calendar[Date] >= MIN(Dogs[Start_Date]) &&
Calendar[Date] <= MAX(Dogs[End_Date])
)
)
Hope this helps!
😁😁