Optional filter on Query Report

I am creating a Query report in ERPNext and following is my query. When I run the report it shows the error “KeyError: ‘customer’”

All I need is to make ‘customer’ filter optional. I know this can be easily done through a script report.
FYI, the report columns and the filters are defined in the report

SELECT
name,
posting_date,
customer,
grand_total,
outstanding_amount
FROM
tabSales Invoice
WHERE (%(customer)s is null or (customer=%(customer)s)
AND
posting_date BETWEEN %(starting_invoice_date)s AND %(ending_invoice_date)s;

SELECT
name,
posting_date,
customer,
grand_total,
outstanding_amount
FROM
tabSales Invoice
WHERE
(customer = %(customer)s OR %(customer)s IS NULL OR %(customer)s = ‘’)
AND
posting_date BETWEEN %(starting_invoice_date)s AND %(ending_invoice_date)s;

@tglk try this

Thanks! Unfortunately, not working.

@tglk refer this Query report filters not working!

Thanks! This was a pretty simple report so I wanted to avoid coding :smiley:

Only option is to go for a script report. Will follow that route.

@tglk check this here is the solution Using filter for Query Report in ERPNext v13