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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Asfaa5
Frequent Visitor

Active Contracts Count by Year/Month

Hello Team,

 

im new to Power Bi. I need a help on Dax Measure calculation of Active Contracts Count by Year/Month.

 

I have a Table "Sales" with 7,65,000 data. Sales Table contains "Policy Number", "Contract Start Date", "Contract End Date".

 

Need output as below :

 

YearMonthActive Count
2019Jan4000
 Feb4500
 Mar5000
 Apr5500
 May6000
 Jun6500
 Jul7000
 Aug7500
 Sep8000
 Oct8500
 Nov9000
 Dec9500
2020Jan9800
 Feb10100
 Mar10000
 Apr11000
 May12000
 Jun11500
 Jul10000
 Aug9000
 Sep7500
 Oct7000
 Nov6500
 Dec6000
2021Jan5500
 Feb5000
 Mar4500
 Apr4000
 May3500
 Jun3000
 Jul2500
 Aug2000
 Sep1500
 Oct1000
 Nov100
 Dec10

 

Can anyone help me on this.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Asfaa5 

Create one date table.

 

Date=Calender(DATE (2010, 1, 1), DATE (2020, 12, 31)).

Then create year and month column in the date table.

 

Then create measure suggested by @Anonymous .

 

And add year, month and measure to your table visual.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Usually in cases like this the best is to create a separate date table contaning all dates covering the time period you want to analyze. The table should not be connected to the data table with any relations.

 

Then you create a measure something like this:

 

 

Active Contracts = CALCULATE(
  COUNTROWS('Sales'),
  FILTER('Sales', 'Sales'[Contract Start Date] <= MAX('Dates'[Date]) && 'Sales'[Contract End Date] >= MIN('Dates'[Date]))
)

 

 

I have assumed each row has one contract, so COUNTROWS('Sales') is the number of contracts.

Finally, use year / month / date from the dates table in combination with the new measure.

Anonymous
Not applicable

Hi @Asfaa5 

Create one date table.

 

Date=Calender(DATE (2010, 1, 1), DATE (2020, 12, 31)).

Then create year and month column in the date table.

 

Then create measure suggested by @Anonymous .

 

And add year, month and measure to your table visual.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Anonymous
Not applicable

What is the required logic for active contracts?

 

Is it where end date in blank() or 12/31/9999?

 

New measure=Calculate(Count[Table[Contract]),Filter(table,Table[end_Date]='12/31/9999')

 

Please modify filter condition as per your active contracts logic.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Hi. Thanks for your revert.

 

Logic is for Showing How many Contract are going to be active in Jan-20, Feb-20, Mar-20, like this till Contract Expire completely.

 

There is no blank in Contract End Date. Last date is till 31/12/2027.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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