Hi All,
i created a new Query report for Lead and i names it as Lead report i written the code
SELECT
lead_owner AS “Lead Owner:Link/User:150”,
custom_product_type AS “Product Type:Select:150”,
COUNT(name) AS “Total Leads:Int:100”,
COUNT(CASE WHEN status = ‘Converted’ THEN 1 END) AS “Converted Leads:Int:100”,
COUNT(CASE WHEN status != ‘Converted’ THEN 1 END) AS “Unconverted Leads:Int:100”,
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) <= 30 THEN 1 END) AS “Leads <= 30 Days:Int:150”,
COUNT(CASE WHEN status = ‘Converted’ AND DATEDIFF(CURDATE(), creation) <= 30 THEN 1 END) AS “Converted <= 30 Days:Int:150”,
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 30 AND DATEDIFF(CURDATE(), creation) <= 60 THEN 1 END) AS “Leads 31-60 Days:Int:150”,
COUNT(CASE WHEN status = ‘Converted’ AND DATEDIFF(CURDATE(), creation) > 30 AND DATEDIFF(CURDATE(), creation) <= 60 THEN 1 END) AS “Converted 31-60 Days:Int:150”,
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 60 AND DATEDIFF(CURDATE(), creation) <= 120 THEN 1 END) AS “Leads 61-120 Days:Int:150”,
COUNT(CASE WHEN status = ‘Converted’ AND DATEDIFF(CURDATE(), creation) > 60 AND DATEDIFF(CURDATE(), creation) <= 120 THEN 1 END) AS “Converted 61-120 Days:Int:150”,
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 120 THEN 1 END) AS “Leads > 120 Days:Int:150”,
COUNT(CASE WHEN status = ‘Converted’ AND DATEDIFF(CURDATE(), creation) > 120 THEN 1 END) AS “Converted > 120 Days:Int:150”
FROM
tabLead
GROUP BY
lead_owner
ORDER BY
lead_owner;
it is working but my problem is when the query report where clicking on the count values in the “Total Leads” column filters it should shows the respective leads,
SELECT
lead_owner AS "Lead Owner:Link/User:150",
custom_product_type AS "Product Type:Select:150",
CONCAT('<a href="/app/lead?lead_owner=', lead_owner, '">', COUNT(name), '</a>') AS "Total Leads:HTML:150",
COUNT(CASE WHEN status = 'Converted' THEN 1 END) AS "Converted Leads:Int:100",
COUNT(CASE WHEN status != 'Converted' THEN 1 END) AS "Unconverted Leads:Int:100",
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) <= 30 THEN 1 END) AS "Leads <= 30 Days:Int:150",
COUNT(CASE WHEN status = 'Converted' AND DATEDIFF(CURDATE(), creation) <= 30 THEN 1 END) AS "Converted <= 30 Days:Int:150",
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 30 AND DATEDIFF(CURDATE(), creation) <= 60 THEN 1 END) AS "Leads 31-60 Days:Int:150",
COUNT(CASE WHEN status = 'Converted' AND DATEDIFF(CURDATE(), creation) > 30 AND DATEDIFF(CURDATE(), creation) <= 60 THEN 1 END) AS "Converted 31-60 Days:Int:150",
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 60 AND DATEDIFF(CURDATE(), creation) <= 120 THEN 1 END) AS "Leads 61-120 Days:Int:150",
COUNT(CASE WHEN status = 'Converted' AND DATEDIFF(CURDATE(), creation) > 60 AND DATEDIFF(CURDATE(), creation) <= 120 THEN 1 END) AS "Converted 61-120 Days:Int:150",
COUNT(CASE WHEN DATEDIFF(CURDATE(), creation) > 120 THEN 1 END) AS "Leads > 120 Days:Int:150",
COUNT(CASE WHEN status = 'Converted' AND DATEDIFF(CURDATE(), creation) > 120 THEN 1 END) AS "Converted > 120 Days:Int:150"
FROM
tabLead
GROUP BY
lead_owner
ORDER BY
lead_owner;
When clicking on “Total lead,” I will be redirected to the lead doctype with the lead_owner filter.
yeah it is working i need also for all filters like Converted Leads, Unconverted Leads, Converted <= 30 Days,Leads 31-60 Days etc it should redirect to the filters
Thanks in Advance
done but i need for example sales user if he open this report his creation only need to show only admin can see the all lead owners report
Thanks in Advance
You don’t want to understand what I want to tell you. Not everything is possible in query report. A server script report has to be created for that. I told you this before