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
pbreslin24
Regular Visitor

Calculating Between 2 dates over 2 months

Hello All! 

 

I am trying to calculate days in each month from a start date and End date that spans over 2 or 3 months. I can get the dates correct for each project just by calculating the difference between dates but i am not able to look at how many days are in each month graphically. Is there a way to add a colum or measure to show how many days are in each month or is there a way to graph how many days are in each month when it is 2 or 3 different months?

 

pbreslin24_0-1624508423652.png

 

Thank you All!

Pbreslin

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@pbreslin24 , I made a similar attempt in past, see if the attached pbix can help

 

or this blog

How to divide/distribute values between start date or end date or count days across months/days: https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@pbreslin24 , I made a similar attempt in past, see if the attached pbix can help

 

or this blog

How to divide/distribute values between start date or end date or count days across months/days: https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

This saved my day, thank you amitchandak!
I have a followup question to this. How would one using your soulution:

Day by Month = CALCULATE(countx(SUMMARIZE(filter(CROSSJOIN('Data','Date'),'Date'[Date] >= 'Data'[StartDate] && 'Date'[Date]<= 'Data'[EndDate]),'Data'[id],'Date'[Date]),'Date'[Date]))

Calculate the value accumulated?
It works perfect specifying the number of days in each month but I need to vizualise the values accumulated over a year and I can't get it to work.

Edited: I believe i have it working now. My mistake was trying to use my own date selection to look at a table with the new measure. I needed to use the new table created and its working. Checked Manually for a few months and its good. Thank you for the help!!

 

Previous:

(Thank you for the reply. When i use this method it still adds the total value into whatever month the Data(startdate) is in. It did not divide the dates into each month. Below is my typed out measure. It is calculating the value correctly for total days between 2 dates. Am i missing part? 

 

Value by day of Month = CALCULATE(SUMX(SUMMARIZE(filter(CROSSJOIN('Work Order','Date'),'Date'[Date] >= 'Work Order'[Account Start Date] && 'Date'[Date]<= 'Work Order'[Account End Date]),'Work Order'[Name],'Date'[Date],'Work Order'[Account Rev Days],'Work Order'[Account Start Date],'Work Order'[Account End Date]),DIVIDE('Work Order'[Account Rev Days],DATEDIFF('Work Order'[Account Start Date],'Work Order'[Account End Date],DAY)+1)))

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.

Top Solution Authors