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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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