And what exactly doesn't work? You need to explain better and in more detail rather than just saying it wouldn't work.
Oops, edit - hadn't woken up yet. It works for me. Perhaps you don't think it was working because the randomly-selected duration is longer than you want. The "minDur" and "maxDur" values specify the minimum and maximum duration (in seconds) that will be randomly selected for the trim paths to complete (ie, reach 100%). Try tweaking those values to taste.
thanks for you help, I don't think I need to do it anymore, i have done something that suits my needs better I think, but just to clarify, I put the expression in the 'end' value in the 'trim paths' (which is what Im using to animate it), and the only changes I have been making to this expression has been the numbers, I have been playing around with it with the vague knowledge of how you describe it and it is never been random for some reason, its always been uniform and sometimes a bit glitchy, I will carry on playing around with it because I'm new to AE so it might well be me missing something obvious.
The expression you found wont be random across invocations; that's by design. It will always generate the same random end point for the given layer # it is on (random seed is based on layer #, which is the variable 'index'). You can change the random # selected for the invocation by varying the seed, for example statically like this: (100 is arbitrary - use any number to change the seed):
You can also vary the seed based on a dynamic element, like the layer's position in time. But doing that would require some modifications to the expression.