Need help with optional filter in SQL query

I want my SQL Query to have a optional {{Year}} filter. So far this query works, I tried getting the where clause into the optional brackets based on the documentation but i can't get it to work.

What I'm trying to do is calculate the percentage of revenue per sources.url. If anyone can help me out I would much appreciate it.

Query without the optional where filter. Works when entering a year variable in metabase

SELECT
    sources.url AS URL,
    (SUM(CASE WHEN leads.status = 'approved' THEN leads.price ELSE 0 END) / 
     (SELECT SUM(CASE WHEN status = 'approved' THEN price ELSE 0 END) FROM leads WHERE YEAR(created_at) = {{Year}})) AS percentage
FROM
    leads
JOIN
    quote_requests ON leads.quote_request_id = quote_requests.id
JOIN
    sources ON quote_requests.source_id = sources.id
WHERE
    YEAR(leads.created_at) = {{Year}}  -- Filter leads created based on the parameter
GROUP BY
    sources.url
ORDER BY
    percentage DESC;

Query with the optional where filter brackets. Works only when entering a year variable in metabase

SELECT
    sources.url AS URL,
    (SUM(CASE WHEN leads.status = 'approved' THEN leads.price ELSE 0 END) / 
     (SELECT SUM(CASE WHEN status = 'approved' THEN price ELSE 0 END) FROM leads [[WHERE YEAR(leads.created_at) = {{Year}}))]] AS percentage
FROM
    leads
JOIN
    quote_requests ON leads.quote_request_id = quote_requests.id
JOIN
    sources ON quote_requests.source_id = sources.id
[[WHERE
    YEAR(leads.created_at) = {{Year}}]]  -- Filter leads created based on the parameter
GROUP BY
    sources.url
ORDER BY
    percentage DESC;