Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MaNUEL2019
New Member

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 numberCustomerInit dateEnd date
42509A01/01/201930/03/2109
42509B01/04/201918/02/2020
42510A01/02/2019 
87836C01/01/2019 

 

I want to have a result like this...

 Customer A   
 ene-19feb-19mar-19abr-19may-19
Machines12211

I have tried with summarize but I cannot adjust by period... 

Any help...

 

Thanks in advance

Regards.

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

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:

xx.png

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.

View solution in original post

2 REPLIES 2
v-alq-msft
Community Support
Community Support

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:

xx.png

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.

KEITHO
Frequent Visitor

I don't think you will be able to do it until you reformat the data.

Each date between init date and end date will have to be associated to the customer and machine serial number. So for example your data should have 89 records for machine serial 42509 for customer A. Alternatively you need at least one record per month present.

 

You can do that with a linked date range table. There's another post here which gives a pretty good outline of using dates:

https://community.powerbi.com/t5/Desktop/Group-dates-to-Month/m-p/166986#M72916

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors