HPCC-10390 Fix internal error generated by <dataset> : WHEN

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Merge pull request #5137 from ghalliday/issue10390

HPCC-10390 Fix internal error generated by <dataset> : WHEN

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>