Forum Discussion
How to count records in a range dates per month
- 6 years ago
Hi, MaNUEL2019
Firstly, you can create a calculated table as follows.
Dates = CalendarAuto()
Secondly, you may create two columns and a measure as below.
FormatDate = FORMAT([Date],"MMM") & "-" & FORMAT('Dates'[Date],"YY")
Machines = "Machines"
Amount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[machine Serial number] ),
FILTER (
FILTER(ALLSELECTED ( 'Table' ),'Table'[Customer] IN FILTERS ( 'Table'[Customer] )),
OR (
[Init date] <= MAX ( 'Dates'[Date] )
&& ISBLANK ( 'Table'[End date] ),
NOT (
OR ( [Init date] >= MAX ( 'Dates'[Date] ), [End date] <= MIN ( 'Dates'[Date] ) )
)
)
)
)
Result:
If I misunderstand your thought, please show me your expected output. I am glad to solve the problem.
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, MaNUEL2019
Firstly, you can create a calculated table as follows.
Dates = CalendarAuto()
Secondly, you may create two columns and a measure as below.
FormatDate = FORMAT([Date],"MMM") & "-" & FORMAT('Dates'[Date],"YY")
Machines = "Machines"
Amount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[machine Serial number] ),
FILTER (
FILTER(ALLSELECTED ( 'Table' ),'Table'[Customer] IN FILTERS ( 'Table'[Customer] )),
OR (
[Init date] <= MAX ( 'Dates'[Date] )
&& ISBLANK ( 'Table'[End date] ),
NOT (
OR ( [Init date] >= MAX ( 'Dates'[Date] ), [End date] <= MIN ( 'Dates'[Date] ) )
)
)
)
)
Result:
If I misunderstand your thought, please show me your expected output. I am glad to solve the problem.
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.