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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
hanuraolm
Helper I
Helper I

populate same records into multiple based on hours spend.

if the particular record downtime (completion time - accept time)e is more than 1 hour, then need to populate multiple records for each hour, else the same record.  see the below

source

hanuraolm_0-1638459828316.png

result

hanuraolm_1-1638459857426.png

 

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    fx=(dt,et)=>List.Min({Time.EndOfHour(dt)-#duration(0,0,0,1),et}),
    DT=(ct,at)=>Duration.TotalHours(ct-at),
    Custom1 = Table.FromRecords(
                                List.TransformMany(
                                                   Table.ToRecords(Source),
                                                   each List.Generate(
                                                                      ()=>_&[
                                                                             CompleteTime=fx([AcceptTime],[CompleteTime]),
                                                                             DownTime=DT(CompleteTime,[AcceptTime])
                                                                            ],
                                                                      each [AcceptTime]<=[CompleteTime],
                                                                      (x)=>x&[
                                                                              AcceptTime=Time.StartOfHour(x[CompleteTime]+#duration(0,1,0,0)),
                                                                              CompleteTime=fx(AcceptTime,[CompleteTime]),
                                                                              DownTime=DT(CompleteTime,AcceptTime)]
                                                                     ),
                                                   (x,y)=>y
                                                  )
                               )
in
    Custom1

View solution in original post

Anonymous
Not applicable

Hi @hanuraolm ,

 

Please go to "Advanced Editor" dialog, and paste the @wdx223_Daniel 's M syntax in it.

In your case, you may need to make some changes as shown below:

Eyelyn9_0-1638860508320.png

 

Best Regards,
Eyelyn Qin

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @hanuraolm ,

 

Please go to "Advanced Editor" dialog, and paste the @wdx223_Daniel 's M syntax in it.

In your case, you may need to make some changes as shown below:

Eyelyn9_0-1638860508320.png

 

Best Regards,
Eyelyn Qin

wdx223_Daniel
Super User
Super User

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    fx=(dt,et)=>List.Min({Time.EndOfHour(dt)-#duration(0,0,0,1),et}),
    DT=(ct,at)=>Duration.TotalHours(ct-at),
    Custom1 = Table.FromRecords(
                                List.TransformMany(
                                                   Table.ToRecords(Source),
                                                   each List.Generate(
                                                                      ()=>_&[
                                                                             CompleteTime=fx([AcceptTime],[CompleteTime]),
                                                                             DownTime=DT(CompleteTime,[AcceptTime])
                                                                            ],
                                                                      each [AcceptTime]<=[CompleteTime],
                                                                      (x)=>x&[
                                                                              AcceptTime=Time.StartOfHour(x[CompleteTime]+#duration(0,1,0,0)),
                                                                              CompleteTime=fx(AcceptTime,[CompleteTime]),
                                                                              DownTime=DT(CompleteTime,AcceptTime)]
                                                                     ),
                                                   (x,y)=>y
                                                  )
                               )
in
    Custom1

thanks for the details. Could you share more details about what you have imported and the final result of that. If you can share the PowerBI file that would help us to set up as per the need. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors