I have a dataset with many continuous columns of data and two categorical factors that I filter on within my dashboard, and an additional Categorical variable (Group) that I use to split all the plots/analyses by. I also have a primary column switcher that means users can cycle through a summary table of each continuous variable. The primary column switcher is linked to all the other column switchers on the plots and analyses within the dashboard. So, any plot and analysis shows one continuous variable at a time and can be filtered by Sex (males/females or both).
This all works well, but the problem arises when I create a new table (dtSumm) that uses the summary statistic table for each continuous variable and calculates a new variable (Relative Change). This new summary table only has as many rows as there are categories of groups, and does not have Sex so we now lose the ability to filter by this.
The code for dtSumm is as follows:
// Create a separate datatable for treatment group means
dtSumm = dt << Summary (
Group (:Group,:Sex ),
Mean ( eval ( cols ) ),
statistics column name format( "column" ),
Link to original data table( 1 ),
invisible
);
// Add RC columns for each column in cols to dtSumm
//This works by getting the mean of each column for treatment group "A"
For( i = 1, i <= num, i++,
mean0 = Mean(Column(cols[i])[(dtSumm << get rows where( :"Group" == "A"))]);
dtSumm << New Column(
Char(cols[i]||"_RC"),
Formula( ( ( ( column( cols[i] )[]) - ( eval(mean0) ) ) / ( eval(mean0) ) ) * 100 )
);
);
Any suggestions welcome. Thanks