I would like to color the cells of a tabular environment as a heatmap, like Unas's solution at Parametrize shading in table through TikZ, but I have negative numbers in the table. I would like to set 0 shade for those cells, but I am not able to set up the if condition appropriately.
I can use the if condition to calculate the "shade" variable well, but it is not allowed to propage the result to a function, if the original number is negative.
Please consider the MWE below. I get "17: Missing number, treated as zero. [\end]" and "17: Illegal unit of measure (pt inserted). [\end]" errors if I try to uncomment line 9 and line 16 in the same time.
\documentclass{article}
\usepackage{xcolor,colortbl}
\usepackage{xintexpr}
\newcommand{\cca}[1]{%
\gdef\shade{\ifnum\numexpr#1<0\relax {\xinttheiexpr 0\relax}\else#1\fi}
\shade
%\ccadoit[10]{#1}% it works
% \ccadoit[0]{#1}% it works
\ccadoit[\shade]{#1}% it works only for \cca{nonnegative_number}
}
\def\ccadoit[#1]#2{\cellcolor{brown!#1}{ #2}}
\begin{document}
\begin{tabular}{r}
\cca{10} \\ % it works
\cca{0} \\ % it works
\cca{-10} \\ % it does not work with \ccadoit[\shade]{#1}
\end{tabular}
\end{document}

