Forum Discussion
Start & End Dates
I have a list of Shows with a start date and an end date. Some cross years and I need to show the total hours on a platform each month and year. So basically I need for each month a formula that say 'if this date is after start and before end date add the hours for this show"...
I have tried a bunch of different formulas and most recently this which is only counting the hours in the End Year.
Hi Anonymous ,
Based on your description, you can try to create this measure:
Hours = VAR _date = SELECTEDVALUE ( 'Calendar'[Date] ) VAR _start = SELECTEDVALUE ( 'Total Programming'[Start] ) VAR _end = SELECTEDVALUE ( 'Total Programming'[End] ) RETURN IF ( ISFILTERED ( 'Calendar'[Date] ), IF ( _date > _start && _date < _end, DATEDIFF ( _start, _date, HOUR ), "not correspond" ), "not correspond" )Attached a sample file that hopes to help you: date hours.pbix
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Greg_Deckler
Community Champion
Anonymous - Open Tickets - https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147
It was designed to work with date intervals/ranges.
- v-yingjl
Community Support
Hi Anonymous ,
Based on your description, you can try to create this measure:
Hours = VAR _date = SELECTEDVALUE ( 'Calendar'[Date] ) VAR _start = SELECTEDVALUE ( 'Total Programming'[Start] ) VAR _end = SELECTEDVALUE ( 'Total Programming'[End] ) RETURN IF ( ISFILTERED ( 'Calendar'[Date] ), IF ( _date > _start && _date < _end, DATEDIFF ( _start, _date, HOUR ), "not correspond" ), "not correspond" )Attached a sample file that hopes to help you: date hours.pbix
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.