Hi Nithin,
You can use Calculated field to group those under last n months and then display using filter or color shelf.
1. First create a calculated field,

2. Add year in the filter shelf to view only that years details.

3.Create N value as a parameter.

4. Now enter N value and add the created calculated field in color shelf to view details. (below shown for N = 1, 3)

Hope this helps you.