How to put conditions in the matrix table?