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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
VenkatTav
Frequent Visitor

Requirement to count based on In date and out date

Hi All,

 

I have a requirement to count the no. of loans which are bankruptcy based on bankruptcy in date and bankruptcy out date, We have to count that loan in every month starting from when the loan went into bankruptcy to loan got out of the bankruptcy.

 

Screeshot of sample data and required output :

VenkatTav_0-1675348528040.png

 

 

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

Hi , @VenkatTav 

According to your description, you want to "count based on In date and out date".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675391374584.png

(2)We need to create a date table as a dimension table . And we do not need to create relationship between two tables.

Date = CALENDAR(DATE(2022,1,1) , LASTDATE('Table'[bankrupty date out]))

(3)Then we need to create a measure:

Measure = var _cur_date  =  MIN('Date'[Date])
var _first_date = EOMONTH(_cur_date  ,-1)+1
var _last_date = EOMONTH(_cur_date,0)+1
var _t = FILTER( ALLSELECTED('Table') , 'Table'[bankrupty date in]<= _first_date && 'Table'[bankrupty date out] >= _last_date)
return
COUNTROWS(_t)+0

 

(4)Then we put the fields we need on the visual and we can meet your need:

vyueyunzhmsft_1-1675391447658.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

What is the purpose of the "Loan date" column there?  Share data in a format the can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yueyunzh-msft
Community Support
Community Support

Hi , @VenkatTav 

According to your description, you want to "count based on In date and out date".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675391374584.png

(2)We need to create a date table as a dimension table . And we do not need to create relationship between two tables.

Date = CALENDAR(DATE(2022,1,1) , LASTDATE('Table'[bankrupty date out]))

(3)Then we need to create a measure:

Measure = var _cur_date  =  MIN('Date'[Date])
var _first_date = EOMONTH(_cur_date  ,-1)+1
var _last_date = EOMONTH(_cur_date,0)+1
var _t = FILTER( ALLSELECTED('Table') , 'Table'[bankrupty date in]<= _first_date && 'Table'[bankrupty date out] >= _last_date)
return
COUNTROWS(_t)+0

 

(4)Then we put the fields we need on the visual and we can meet your need:

vyueyunzhmsft_1-1675391447658.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@VenkatTav , refer if these approaches can help

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

Measure way
Power BI Dax Measure- Allocate data between Range: https://youtu.be/O653vwLTUzM
https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

Matrix as Project plan Visual: https://youtu.be/R25QoiyoSVs

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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