Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi everyone
It´s my 1st time asking for help to the community... Hoping for the best!
I need to define, for each row in a table, a random time between 4 defined parameters.
That random time is being calculated by calling, for each row, a custom Function (RandomTime), which works with those set parameters:
Custom3 = Table.AddColumn(Custom2, "Hora Corte Reparto AJ",
each
RandomTime(#"1er Slot Preparacion RNA",#"2do Slot Preparacion RNA",#"3er Slot Preparacion RNA",#"4to Slot Preparacion RNA")),
The calculation is being done correctly, but the problem is that the result for each row is the same, and I do not know where the problem lies....
Any ideas on how to solve this?
Much appreciated!
The custom functions are the following =>
(A,B,C,D as time) =>
let
RandomA = Number.From(A),
RandomB = Number.From(B),
RandomC= Number.From(C),
RandomD= Number.From(D),
Random1 =Number.RandomBetween(RandomA,RandomB),
Random2 =Number.RandomBetween(RandomC,RandomD),
ResultadoRandom=Number.RandomBetween(Random1,Random2),
Delta1=Number.Abs(Random1-ResultadoRandom),
Delta2= Number.Abs(Random2-ResultadoRandom),
RandomFinal= if Delta1<=Delta2
then Random1
else Random2,
RandomFinal2 = RoundownTime(Time.From(RandomFinal),TimeSlot)
in
RandomFinal2
(TimeToRound as time,TimeSlot as number ) =>
let
Source = TimeToRound,
#"Convert datetime to decimal" = Number.From(Source),
#"Upscale number" = #"Convert datetime to decimal"*(24*60/TimeSlot),
#"Round to nearest minute" = Number.Round(#"Upscale number"),
#"Downscale number" = #"Round to nearest minute" / (24*60/TimeSlot),
#"Convert back to time" = Time.From(#"Downscale number")
in
#"Convert back to time"
Just to showcase the result I'm getting rigth now..
Hi! @Nacho_P ,
Can you please share the sample data and desired output that you need?
Hi @AnkitKukreja , thank you for your reply.
The desired outcome is, for each row, a different randomized time based on the parameters which the custom function computes.
The problem I'm having is that, although I'm using an each statement, the random number is not generated for each row, but instead becomes fixed for the whole iteration.
The custom function requires 4 time parameters, and the result should be a random time that falls between A-B or between B-C.
Those time parameters currently are:
A)8:00
B)11:40
C)14:20
D)19:40
Hope this adds clarity to my question.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.