| If your data is in Excel you could use a pivot table to get this result. If you are creating a query, say in Microsoft Access, this is called a “transform” query. In either case, we are taking the PassFail column from the original data and turning this into multiple columns in the result data. In the example, we get a PASS column and a FAIL column.
In the attached .zip file, you will find an Access 2000 database and a CHARTrunner 1.6.x chart definition which demonstrate a solution to this problem. You will see that the chart is defined against a query that is stored in the Access database. Don’t be intimidated by this “transform” query. It looks complex, but it is only text that tell the database to do some work for us. It can easily be cut and pasted into your database and then altered to match your table and field names.
To study the solution to this problem, follow these steps:
Unzip the attached file into some temporary folder. Run CHARTrunner 1.6.x or higher. Set the CHARTrunner working folder to the folder you just created. Take a look at the chart and the chart definition. If you have Access 2000, you can look at the query by opening the Access database.
If you do not have Access 2000, here is the text of the query used to solve this problem:
TRANSFORM
iif(IsNull(count([pfdata].PassFail)),0,count([pfdata].PassFail)) AS CountOfPassFail
SELECT Min([pfdata].DATE) AS ProductionDate, Count([DATE]) AS Total FROM pfdata GROUP BY [pfdata].DATE ORDER BY [pfdata].DATE PIVOT [pfdata].PassFail;
Some things to note about this query:
The use of the IIF function (known as immediate if) is not standard SQL. This may not work for data in Oracle or other SQL databases. Without the IIF, the query will return an empty cell for days where there are NO failures. For a p-chart it is better to get an actual zero. To get a count for each date, we must use the count function and the group by clause. To get a separate column for PASS and FAIL, we use pivot. |