Generating random conversions

I would use \ifcase instead:

\documentclass{article}
\usepackage[first=1,last=7,counter=grooth]{lcg}

\newcommand\randFloat{{%
    \reinitrand[first=0, last=100, counter=var]
    \rand\arabic{var}.\rand\arabic{var}}}

\rand\gdef\OldRand{\thegrooth}

\newcommand\randGrooth{%
    \rand\ifnum\thegrooth=\OldRand \rand \fi
    \ifcase\thegrooth mm  % 0
      \or mm              % 1
      \or cm              % 2
      \or dm              % 3
      \or m               % 4
      \or dam             % 5
      \or hm              % 6
      \or km              % 7
    \fi
    \gdef\OldRand{\thegrooth}%
}

\begin{document}

\begin{tabular}{ll}
44.36\,mm =& \hspace*{10 ex} m\\
56.28\,dm=& \hspace*{10 ex} km
\end{tabular}

\bigskip
\begin{tabular}{ll}
\randFloat\,\randGrooth =& \hspace*{10 ex} \randGrooth\\
\randFloat\,\randGrooth =& \hspace*{10 ex} \randGrooth  
\end{tabular}

\bigskip
\begin{tabular}{ll}
\randFloat\,\randGrooth =& \hspace*{10 ex} \randGrooth\\
\randFloat\,\randGrooth =& \hspace*{10 ex} \randGrooth  
\end{tabular}
\end{document}

enter image description here


This solution uses pdftex primitives, so it needs pdflatex to run. The units are typeset with siunitx package, they are organized into an array by means of \csname.

\documentclass{article}
\usepackage{siunitx}
\sisetup{round-mode = places,round-precision = 2}
%
\pdfsetrandomseed12345 %
%
\newcommand{\randFloat}{\pdfuniformdeviate100\expandafter.\pdfuniformdeviate100 }
%
\expandafter\def\csname0\endcsname{\si{\milli\metre}}
\expandafter\def\csname1\endcsname{\si{\centi\metre}}
\expandafter\def\csname2\endcsname{\si{\deci\metre}}
\expandafter\def\csname3\endcsname{\si{\metre}}
\expandafter\def\csname4\endcsname{\si{\deca\metre}}
\expandafter\def\csname5\endcsname{\si{\hecto\metre}}
\expandafter\def\csname6\endcsname{\si{\kilo\metre}}
%
\newcounter{ucount}
\newcommand{\incUcount}{%
\addtocounter{ucount}{\pdfuniformdeviate6 }%
\ifnum\arabic{ucount}>6 \addtocounter{ucount}{-7}\fi %
\expandafter\csname\arabic{ucount}\endcsname}

\newcommand{\randGrooth}{%
\incUcount\stepcounter{ucount} &= \hspace*{6 em}\incUcount\setcounter{ucount}{0}%
}

\begin{document}

\begin{table}
\centering
\begin{tabular}{Sll}
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth \\ 
\randFloat & \randGrooth    
\end{tabular}

\end{table}
\end{document}

enter image description here