Hi @techg ,
For all the 3 parameters you need to create widgets.
The default should be the empty string
CREATE WIDGET TEXT country DEFAULT '';
CREATE WIDGET TEXT period DEFAULT '';
CREATE WIDGET TEXT Document DEFAULT '';
You assign 2 values for country and period, leaving Document an empty string:
The query:
SELECT *
FROM sample_table
WHERE
(
:country IS NULL OR :country = '' OR country = :country
)
AND (
:period IS NULL OR :period = '' OR period = :period
)
AND (
:Document IS NULL OR :Document = '' OR Doc = :Document
);
Sample data:
-- Create a sample table
CREATE OR REPLACE TABLE sample_table (
country STRING,
period STRING,
Doc STRING,
value INT
);
-- Insert sample data
INSERT INTO sample_table VALUES
('USA', '2021', 'Doc1', 100),
('USA', '2022', 'Doc2', 200),
('Canada', '2021', 'Doc3', 150),
('Canada', '2022', 'Doc4', 250),
('Mexico', '2021', 'Doc5', 300);
The result of query on sample data:
The error message suggest that even though you the Document parameter is expected in the query, it is not not defined in your code. Make sure to define the parameter before using it.