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
idkhonestlyanyt
New Member

Finding out if a contract is active or not based on dynamic date filter

So I have my datetable which contains the columns: Date, MonthYear, Fiscal Year, Fiscal Quarter.

I have my contract table which contains:
Contract ID, StartDate, EndDate. 

The two are not connected. I want to find out the number of active contracts based on the date slicer. Example, there is a contract that started on 9th Feb, 2020 and ends on Feb 30, 2027. If I select the option on MonthYear column: June, 2024, this contract should count as 1. How do I go about this? The next part was trying to find out the new contracts added since last month based on the date selected and the contracts expired based in the last month based on the date selected. 

Is this possible?

Example data:

Contract IDRelationshipStartDateRelationshipEndDate
7862020-02-07 0:002025-10-21 0:00
10782020-02-07 0:002025-08-21 0:00
13162021-08-18 0:002025-11-13 0:00
17202020-02-07 0:002025-03-25 0:00
30422020-02-07 0:002025-03-06 0:00
35812023-01-12 0:002025-05-08 0:00
95492020-02-07 0:002026-01-09 0:00
121502020-02-07 0:002025-06-07 0:00
133532020-02-07 0:002025-03-05 0:00
133762020-02-07 0:002025-12-13 0:00
149452020-02-07 0:002026-01-11 0:00
185252021-08-23 0:002025-08-21 0:00
217452020-02-07 0:002025-07-11 0:00
219812020-02-07 0:002025-03-17 0:00
306582020-02-07 0:002025-09-26 0:00
333962020-02-07 0:002026-01-06 0:00
360552020-02-07 0:002025-04-29 0:00
2 REPLIES 2
divyed
Super User
Super User

Hello @idkhonestlyanyt ,

 

How did you calculate your output ? Please share data to support your output. Also You have passed Feb 30 2027 as input which is not valid. Kindly share relevant data and ouput to ceck further.

 

Meanwhile you can try few things like 

 

Active Contracts =
VAR SelectedDate = MAX(DateTable[Date])
RETURN
CALCULATE(
COUNT(Contracts[Contract ID]),
Contracts[StartDate] <= SelectedDate,  
Contracts[EndDate] > SelectedDate 
)

 

New Contracts =
VAR SelectedMonth = MAX(DateTable[MonthYear])
VAR PreviousMonth = FORMAT(EDATE(MAX(DateTable[Date]), -1), "YYYY-MM")
RETURN
CALCULATE(
COUNT(Contracts[Contract ID]),
FORMAT(Contracts[StartDate], "YYYY-MM") = PreviousMonth
)

 

Expired Contracts =
VAR SelectedMonth = MAX(DateTable[MonthYear])
VAR PreviousMonth = FORMAT(EDATE(MAX(DateTable[Date]), -1), "YYYY-MM")
RETURN
CALCULATE(
COUNT(Contracts[Contract ID]),
FORMAT(Contracts[EndDate], "YYYY-MM") = PreviousMonth
)

 

I hope this helps.

 

Warm Regards,

LinkedIn : https://www.linkedin.com/in/neeraj-kumar-62246b26/
Irwan
Super User
Super User

hello @idkhonestlyanyt 

 

the expected value for June,2024 is 1, but i dont see any data in 2024 in your sample data.

is this the result of the sample data given above?

 

Thank you

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.