siunitx in tabularx

I have a tabularx-table with a lot of SI values. For this, I wanted to define a new column type u which places the contents of the column into a \SI{XXX}{cm} expression.

\newcolumntype{u}{>{\SI\begingroup}{X}<{\endgroup{cm}}}


Using this in a tabularx-table throws me an "Illegal pream token X" and "invalid-token-in-number" exception. Replacing X with c leaves me with only the "invalid-token"-exception. What can I do to make this work?

One way to do what you desire is to use the collcell package:

Code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{collcell}

\newcommand{\MyCommand}[1]{\SI{#1}{cm}}

\newcolumntype{u}{>{\collectcell\MyCommand}{l}<{\endcollectcell}}

\begin{document}
\begin{tabular}{l u}
\toprule
1 inch  & 2.54 \\
1 meter & 100  \\
\bottomrule
\end{tabular}
\end{document}