Forum Discussion

MaNUEL2019's avatar
MaNUEL2019
New Member
6 years ago
Solved

How to count records in a range dates per month

Hi Guys,  Maybe you can help me on this... I want to know how many machines per month I have in a customer based on this table machine Serial number Customer Init date End date 42509 A ...
  • v-alq-msft's avatar
    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.