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
Anonymous
Not applicable

Cummulative hours from start to end date

Hi,

 

I´m trying to show cummulative hourse on a visualization, the thing is that i have two dates. Start and End Date.
I have this table:

CourseTotal HoursStard DateEnd Date
110001/07/201908/09/2019
25005/03/201908/06/2019
33521/07/201921/09/2019
41515/09/201908/12/2019

 

I need to show accumulative hours from thouse dates. The thing is that if i show this on a visualization, i can only put on X axis only one date, Start or End Date. How can i manage this?
If i make a "Calendar table" i can only relation it with or either Start Date or End date

 

Thanks

8 REPLIES 8
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
Anonymous
Not applicable

Hi @Icey,

Sorry is not solved. What I need to do is to make an average of amount of hours.
For example if you finish a course which start on April and finish on July; and the total course hours is 100, you would probably achieve 25 hours per month.
Do i explain myself? And this should be calculated base on start and end date that i mentioned
Thanks
Icey
Community Support
Community Support

Hi @Anonymous ,

You can use DATEDIFF function. These are my measures:

Days = DATEDIFF ( MAX ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ), DAY )
Hours per Day = DIVIDE ( MAX ( 'Table'[Total Hours] ), [Days] )
Months = DATEDIFF ( MAX ( 'Table'[Start Date] ), MAX ( 'Table'[End Date] ), MONTH )
Hours per Month = DIVIDE ( MAX ( 'Table'[Total Hours] ), [Months] )

Cummulative hours from start to end date - follow.PNG

This is my PBIX file.

 

Best Regards,

Icey

 

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

Anonymous
Not applicable

Hi @Icey 

 

That solution is perfect. The thing is that i have some courses that start and end in the same month. So when i execute those mesures i have some "Total hourse per month" in blank. And when i try to put an "Alternative result" when is "0" i can only put an constant numeric value (according to Power BI). And i need that in case of beeing "0" months it should show "Total Hours" column

 

Hope you understand


Regards

Icey
Community Support
Community Support

Hi @Anonymous ,

For Month = 0, try this:

Hours per Month =
IF (
    [Months] = 0,
    MAX ( 'Table'[Total Hours] ),
    DIVIDE ( MAX ( 'Table'[Total Hours] ), [Months] )
)

Best Regards,
Icey

 

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

Anonymous
Not applicable

Hi ICEY

This is almost ready. 
The thing is that when i show this on a visualization it doesent work well.
This is because, when i put in a X Axis the month, (taken from End Date) I lose information.
See below:

TotalHorasStartDateEndDateMonthsHours per Month
4803/05/201927/08/2019316
4803/05/201927/08/2019316
4803/05/201927/08/2019316

 

But the 16 hours are only shown on month Agost or month May (depending on what date i use - Start or End)

I need that the 16 hs apear on June, July, And Agost.


Thanks!

Hi,

In a simple Table, please show the exact expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Icey
Community Support
Community Support

Hi @Anonymous ,

You can create a column like this:

Start - End = COMBINEVALUES ( " - ", 'Table'[Start Date], 'Table'[End Date] )

Cummulative hours from start to end date.PNG

 

Best Regards,

Icey

 

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

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.