1. You can form group of those you require to be mandatory and the vice versa using calculated field.
2. Now add the values that you require using any aggregation or a check operation and form groups.
3. Now add the group that you want optional in filter and place the field in row/ column shelf.
Hope this helps you.