I want to sum the numbers of the last 3 columns in mytable (see below). If all the dates in column A are different, the MWE works fine giving the proper sums (see MWE). But I wish to list Date-1 in only the first row of column A in and leave the remaining rows of column A blank. In this latter situation, the program fails giving an error message: "...an unbalanced number of columns...". Since all the data refers to Date-1 (not Date-2, Date-3, etc), I'd really appreciate a solution. Thanks.


\newcommand{\addsomestatistics}[3]{ %
% #1=table name
% #2=first column name
% #3=list of columns to decorate
% Transpose the table, so we can work on rows instead of columns
\pgfplotstabletranspose[colnames from={#2},input colnames to={#2}]{\intermediatetable}{#1}
% Sums for each column
   create col/assign/.code={%
      \foreach \i in {#3} {
          \pgfplotsforeachungrouped \col in {1,...,\maxcolindex}{
      \pgfkeyslet{/pgfplots/table/create col/next content}\entry
% Transpose back to the original form
\pgfplotstabletranspose[colnames from=#2, input colnames to=#2]{\statstable}{\intermediatetable}


    A B C D E F
   Date-1   Ken Tod 202  12  0
   Date-2      Wood    Haz 317 1 0
   Date-3     Front    -   102 10  0
    Date-4     Front Haz 145 11  0


  every head row/.style={%
    before row={\toprule
 %%       & \multicolumn{3}{c}{Handedness}\\
    after row=\midrule},
  every last row/.style={after row=\bottomrule},
  columns/A/.style={string type},
  columns/B/.style={string type},
   columns/C/.style={string type},
  columns={A,B, C, D, E, F},


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.