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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mostvp123
Kudo Collector
Kudo Collector

Custom Column to Separate Dates Help

Hi!

I am currently working in the query editor with some 'date from' 'date to' data which records activities that people have to do in the future in hours. A sample for the data is as follows:

Ex1.JPG
The data in this format is hard to use, so based on reccomendations from a different forum, I added a custom column which splits up the Date from, Date to columns into separate days as follows (see Date column):

Ex2.JPG

This custom column is added by clicking on "Add Column" and then "Custom Column" in the query editor, with the code: ={Number.From([Date from])..Number.From([Date to])}
This works fine, however as can be seen above, the Hours column is simply repeated and is not divided by the number of new rows. Since the Dates have been split up, the hours must be divided. This is the desired result:Ex3.JPG
I can't seem to figure out a way to do this. Thank you for helping me out 🙂

1 ACCEPTED SOLUTION
AnthonyTilley
Solution Sage
Solution Sage

you could create a calculated colunm to divide the hours by a count of the activity id 

Column =
Var hours = Table1[Hours]
var a = Table1[Activity]
 Var ca = CALCULATE(count(Table1[Activity]),FILTER(Table1,Table1[Activity] = a))
Var ret = DIVIDE(hours,ca)
Return ret

 
Alternativly if you would prefer to have this already cacluated in teh query then add a second custom colunm before your split down step to divid the hours by the total days (you need to add 1 day to your date to as your times are all midnight so this would mean teh number fo days between 01/01/2019 and 02/01/2019 would be 1 day not 2.
Formula below
= [Hours] / Duration.Days(Date.AddDays([Date to],1)-[Date From])
 
insert this add colunm between your added sutom and expanded date steps




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
AnthonyTilley
Solution Sage
Solution Sage

you could create a calculated colunm to divide the hours by a count of the activity id 

Column =
Var hours = Table1[Hours]
var a = Table1[Activity]
 Var ca = CALCULATE(count(Table1[Activity]),FILTER(Table1,Table1[Activity] = a))
Var ret = DIVIDE(hours,ca)
Return ret

 
Alternativly if you would prefer to have this already cacluated in teh query then add a second custom colunm before your split down step to divid the hours by the total days (you need to add 1 day to your date to as your times are all midnight so this would mean teh number fo days between 01/01/2019 and 02/01/2019 would be 1 day not 2.
Formula below
= [Hours] / Duration.Days(Date.AddDays([Date to],1)-[Date From])
 
insert this add colunm between your added sutom and expanded date steps




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors