I created this report to answer the Question from Jaspersoft Community .

1) Create a report with parameters. (I have used P_CITY and P_COUNTRY as parameters and the SQL Code I have used is as below)

SQL Query
SQL Query

2) This Query will take either P_COUNTRY as a parameter input and will display Country level data or P_CITY as parameter value and display city level data.

3) Now create a Variable which will display Country Names when P_COUNTRY is selected as the parameter and will display City names when P_CITY is selected as parameter.

DA_Img2

4) Now create a Chart with this newly created variable as Category Field.

DA_Img3

5) The Report design of my report looks like this.

DA_Img4

6) Now when we preview the report, we needto provide teh parameter value. For teh purpose of this tutorial I added “Rio de Janeiro” as the value for P_CITY Parameter and left P_COUNTRY as Null.

DA_Img5

7) The Result is as follows. (Check the X-axis and Y axis carefully)

DA_Img6

8) Now P_CITY is kept Null and P_Country is updated as “Brazil”

DA_Img7

9) The Result is as follows.

DA_Img8

This is one way to Dynamically change the X-Axis values as per the parameter selection.

The above report is free for your download

Hope this helps you all!!!! For more information on Jaspersoft keep loked in 🙂