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
s--turn
Helper I
Helper I

Identifying which year-ends (Dec 31st) are between two dates

Hello,

 

I need to be able to produce counts for the total number of subscriptions that were active as of December 31st each year.  This is the kind of raw data I have:

 

Subscription IDValid FromValid To
123-XYZ01/01/202131/12/2021
456-ABC04/10/202031/12/2021

 

If they were all complete years like the top row, I would just use the Valid To date.  However, records like the bottom row needs to be identified as active on both 31st December 2020 and 2021. 

 

I ultimately want to be able to get something like this:

Year-EndCount of Subscriptions
20201
20212

 

Any ideas?

 

Many thanks!

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

Hi @s--turn ,

 

You can try this measure.

 

Count of Subscriptions =
CALCULATE (
    COUNT ( 'Table'[Subscription ID] ),
    FILTER (
        'Table',
        'Table'[Valid From] <= MAX ( 'Calendar'[Date] )
            && 'Table'[Valid To] >= MAX ( 'Calendar'[Date] )
    )
)

 

Result is as below.

RicoZhou_1-1666852801416.png

 

Best Regards,
Rico Zhou

 

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
s--turn
Helper I
Helper I

Thank you, @v-rzhou-msft ! Much appreciated.

v-rzhou-msft
Community Support
Community Support

Hi @s--turn ,

 

You can try this measure.

 

Count of Subscriptions =
CALCULATE (
    COUNT ( 'Table'[Subscription ID] ),
    FILTER (
        'Table',
        'Table'[Valid From] <= MAX ( 'Calendar'[Date] )
            && 'Table'[Valid To] >= MAX ( 'Calendar'[Date] )
    )
)

 

Result is as below.

RicoZhou_1-1666852801416.png

 

Best Regards,
Rico Zhou

 

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.