A bar graph is a chart that uses bars to show comparisons between categories of data. The bars can be either horizontal or vertical. There are two types of the bar chart.

In QMetry, the Advance SQL Query provides an ability to generate both the charts as with the required values; let’s understand how both types of bar charts can be generated by writing a SQL queries in detail.

Basic Bar Chart

Let’s take an example of a normal Bar Chart report.

Report : Generate a bar chart that displays the Count of the requirements by status

note

Count Of Requirements By Status

Count Of Requirements By Status

SELECT
COUNT(requirements.entityKey) as "Requirement Count",
requirements.requirementStatus as "Status"
FROM requirements
WHERE requirements.projectID in (`@filter.project`)
GROUP BY requirements.requirementStatus

Apply the Filter

Query Output

By default, it gives you output in tabular format. You can modify the output format by switching to the available chart types from the table. In our case, we will switch it to the Bar Chart.

You can adjust the data columns based on your requirement to Label and Data section.

Once you get your desired report, you can save the report as a Gadget by clicking on the Add Gadget button.

Once you save the gadget, it will be available in the QMetry Custom Gadget section > My Gadget tab.

Stacked Bar Chart

Let’s take an example of a Stacked Bar Chart report.

Report : Generate a bar chart that displays the Count of the test cases by status over priority.

SQL Query

note

Count Of Test Cases By Status Over Priority

Count Of Test Cases By Status Over Priority

SELECT
count(*) as "Test Case Count",
COALESCE(testcases.priority, 'No Priority') as "Test Case Priority",
COALESCE(testcases.testCaseStatus, 'No Status') as "Test Case Status"
FROM testcases
WHERE testcases.projectID in (`@filter.project`)
GROUP BY testcases.priority, testcases.testCaseStatus

Apply the Filter

Query Output

By default, it gives you output in tabular format. You can modify the output format. You can switch to the available chart types from the table. In our case, we will switch it to the Bar Chart.

You can adjust the Columns based on the requirement to Label, Data and Cross Tab sections.

Once you get your desired report, you can save the report as a Gadget by clicking on the Add Gadget button.

Once you save the gadget, it will be available in the QMetry Custom Gadget section > My Gadget tab.