Hello!
I am looking to display a percentage with a donut chart in APEX. The percentage is found by dividing two select count sql statements by each other. I used the following sql statement to find this value, which works:
SELECT CONCAT(CAST((YES_INT * 100.0) / TOTAL_INT AS VARCHAR(20)), '%')
FROM
(SELECT COUNT(OPP) AS YES_INT
FROM ACTION_ITEM
WHERE Opp = 'yes'),
(SELECT COUNT(TITLE) AS TOTAL_INT
FROM ACTION_ITEM)
However, when selecting the value in the column mapping section in order to create the chart, I receive a "wrong data type" error. I am not sure how to alter my SQL to be the correct data type to create a chart in APEX.
Please let me know if there is any additional background information I need to provide. Thank you very much!
Stop casting the result to a string! The values for this chart must be numbers.
I'm unsure exactly what you're trying to show, grouping by OPP may be what you're looking for:
SELECT Opp, COUNT(TITLE) AS TOTAL_INT
FROM ACTION_ITEM
GROUP BY Opp
You can make the values display as percentages by setting the series to:
Series -> Label -> Display As -> Label - Percentage