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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ToddMate
Helper II
Helper II

Month on Month : Count of Active Services

Hi,

 

I’m trying to build a matrix that will count the number of services I have that are active as at the close of each month.

 

For example we sell subscription services that have a Connected date and a Disconnected date, what I am trying to do is count the number of active services as at the end of each month.

 

To determine an active service the Connection date must be prior to the end of the month and the disconnection date was greater than the end of the month.

 

In terms of structure, each row of the table stores the unique Service ID along with the Connected date and Disconnected date on the same row.

 

Can anyone help.


MonM.jpg

Cheers

Todd

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

Hi @ToddMate ,


My original data:
a13.PNG
First, I create a table with DAX:

Table = CALENDAR(DATE(2019, 5, 1), DATE(2019, 12, 31))

Second, I create two measures:

Maxdate each month = 
CALCULATE(
    MAX('Table'[Date]),
    ALLEXCEPT(
        'Table',
        'Table'[Date].[Year], 'Table'[Date].[Month]
    )
)
Mindate each month = 
CALCULATE(
    MIN('Table'[Date]),
    ALLEXCEPT(
        'Table',
        'Table'[Date].[Year], 'Table'[Date].[Month]
    )
)

Third, I count the [service ID] with measure:

Active service = 
CALCULATE(
    COUNT([Service ID]),
    FILTER(
        ALLSELECTED(Sheet10),
        [Connected Date] <= [Mindate each month]
        &&
        [Disconnected Date] >= [Maxdate each month]
    )
)

The result:

a15.PNG

Best regards,
Lionel Chen

 

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

1 REPLY 1
v-lionel-msft
Community Support
Community Support

Hi @ToddMate ,


My original data:
a13.PNG
First, I create a table with DAX:

Table = CALENDAR(DATE(2019, 5, 1), DATE(2019, 12, 31))

Second, I create two measures:

Maxdate each month = 
CALCULATE(
    MAX('Table'[Date]),
    ALLEXCEPT(
        'Table',
        'Table'[Date].[Year], 'Table'[Date].[Month]
    )
)
Mindate each month = 
CALCULATE(
    MIN('Table'[Date]),
    ALLEXCEPT(
        'Table',
        'Table'[Date].[Year], 'Table'[Date].[Month]
    )
)

Third, I count the [service ID] with measure:

Active service = 
CALCULATE(
    COUNT([Service ID]),
    FILTER(
        ALLSELECTED(Sheet10),
        [Connected Date] <= [Mindate each month]
        &&
        [Disconnected Date] >= [Maxdate each month]
    )
)

The result:

a15.PNG

Best regards,
Lionel Chen

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.