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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PBI_newuser
Post Prodigy
Post Prodigy

How to calculate distinct count of product by considering start date and end date

Hi, I want to calculate Contract Pentration in each month but not sure how to create such measure. 

  • Contract Penetration = Products under Contract / Total Active Products 

One product can more than one contract as it renews after the contract is expired. Some products don't renew contract after it expired. 

For example, in 2021-01, Product A,B,D are installed before or on 2021-1 and hence total active products = 3.

In 2021-02, product A,B,D,E are installed before or on 2021-02 and hence the total active products = 4. But in 2021-02, Product E's contract starts from 2021-03 so Products under Contract = 3.

In 2021-09, Product B has no renew contract. Only Product A and E has active contracts. Hence the Products under Contract = 2.

 

ProductContract NumberStart DateEnd DateInstall Date
ACN-11108/17/202108/16/202201/10/2019
ACN-22208/17/202008/16/202101/10/2019
ACN-33308/17/201908/16/202001/10/2019
BCN-44409/16/201509/15/202005/11/2009
BCN-55509/16/202008/31/202105/11/2009
CCN-666  08/03/2021
DCN-77712/01/201903/30/202105/09/2019
ECN-88803/10/202103/09/202202/13/2021

 

Expected Result:

MonthProducts under ContractTotal Active ProductsContract Penetration
2021-0133100%
2021-023475%
2021-0344100%
2021-043475%
2021-053475%
2021-063475%
2021-073475%
2021-083560%
2021-092540%
2021-102540%
2021-112540%
2021-122540%

 

PBI_newuser_0-1647485472928.png

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@PBI_newuser , refer if the attached file can help

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Products under contract: = 
IF (
    HASONEVALUE ( 'Calendar'[Year-Month] ),
    COUNTROWS (
        SUMMARIZE (
            FILTER (
                Data,
                Data[Start Date] <= MAX ( 'Calendar'[Date] )
                    && Data[End Date] >= MIN ( 'Calendar'[Date] )
            ),
            Data[Product]
        )
    )
)

 

Products Active: = 
IF (
    HASONEVALUE ( 'Calendar'[Year-Month] ),
    COUNTROWS (
        SUMMARIZE (
            FILTER ( Data, Data[Install Date] <= MAX ( 'Calendar'[Date] ) ),
            Data[Product]
        )
    )
)

 

Ratio measure: = 
DIVIDE ( [Products under contract:], [Products Active:] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I suggest having a calendar table like below.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Products under contract: = 
IF (
    HASONEVALUE ( 'Calendar'[Year-Month] ),
    COUNTROWS (
        SUMMARIZE (
            FILTER (
                Data,
                Data[Start Date] <= MAX ( 'Calendar'[Date] )
                    && Data[End Date] >= MIN ( 'Calendar'[Date] )
            ),
            Data[Product]
        )
    )
)

 

Products Active: = 
IF (
    HASONEVALUE ( 'Calendar'[Year-Month] ),
    COUNTROWS (
        SUMMARIZE (
            FILTER ( Data, Data[Install Date] <= MAX ( 'Calendar'[Date] ) ),
            Data[Product]
        )
    )
)

 

Ratio measure: = 
DIVIDE ( [Products under contract:], [Products Active:] )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@PBI_newuser , refer if the attached file can help

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.