This query below works in Metabase as-is (without text variable in WHERE clause)
But changing the clause
where customer ='Ford'
to
[[where customer = {{customer_var}}]]
and setting customer_var = Ford
returns this error...
The column index is out of range: 1, number of columns: 0.
How can this happen?
select *
from crosstab (
$$ select array[component, version]::text[], customer, master_local_family, local_family, int_month, SUM(component_requirement)
from tbl_monthly_ctb_demand
where customer = 'Ford'
group by component, version, customer, master_local_family, local_family, int_month
ORDER BY 1 $$,
$$ values ('202001'),('202002'),('202003'),('202004'),('202005'),('202006'),('202007'),('202008'),('202009'),('202010'),('202011'),('202012'),
('202101'),('202102'),('202103'),('202104'),('202105'),('202106'),('202107'),('202108'),('202109'),('202110'),('202111'),('202112'),
('202201'),('202202'),('202203'),('202204'),('202205'),('202206'),('202207'),('202208'),('202209'),('202210'),('202211'),('202212') $$)
AS ct(
row_id text[],
customer text,
master_local_family text,
local_family text,
Jan20 numeric(12,3),
Feb20 numeric(12,3),
Mar20 numeric(12,3),
Apr20 numeric(12,3),
May20 numeric(12,3),
Jun20 numeric(12,3),
Jul20 numeric(12,3),
Aug20 numeric(12,3),
Sep20 numeric(12,3),
Oct20 numeric(12,3),
Nov20 numeric(12,3),
Dec20 numeric(12,3),
Jan21 numeric(12,3),
Feb21 numeric(12,3),
Mar21 numeric(12,3),
Apr21 numeric(12,3),
May21 numeric(12,3),
Jun21 numeric(12,3),
Jul21 numeric(12,3),
Aug21 numeric(12,3),
Sep21 numeric(12,3),
Oct21 numeric(12,3),
Nov21 numeric(12,3),
Dec21 numeric(12,3),
Jan22 numeric(12,3),
Feb22 numeric(12,3),
Mar22 numeric(12,3),
Apr22 numeric(12,3),
May22 numeric(12,3),
Jun22 numeric(12,3),
Jul22 numeric(12,3),
Aug22 numeric(12,3),
Sep22 numeric(12,3),
Oct22 numeric(12,3),
Nov22 numeric(12,3),
Dec22 numeric(12,3)
);