<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Missing selection for Parameter error in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100717#M40390</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133987"&gt;@techg&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;For all the 3 parameters you need to create widgets.&lt;BR /&gt;The default should be the empty string&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CREATE WIDGET TEXT country DEFAULT '';
CREATE WIDGET TEXT period DEFAULT '';
CREATE WIDGET TEXT Document DEFAULT '';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You assign 2 values for country and period, leaving Document an empty string:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_0-1733213559743.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/13288i9E720FE09823975E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_0-1733213559743.png" alt="filipniziol_0-1733213559743.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The query:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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
  );&lt;/LI-CODE&gt;&lt;P&gt;Sample data:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;-- 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);&lt;/LI-CODE&gt;&lt;P&gt;The result of query on sample data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_1-1733213659183.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/13289iF5F31337BEC45110/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_1-1733213659183.png" alt="filipniziol_1-1733213659183.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Dec 2024 08:18:33 GMT</pubDate>
    <dc:creator>filipniziol</dc:creator>
    <dc:date>2024-12-03T08:18:33Z</dc:date>
    <item>
      <title>Missing selection for Parameter error</title>
      <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100580#M40339</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have created three parameters in an SQL query in Databricks. If no value is entered for a parameter, I would like the query to retrieve all values for that particular column. Currently, I'm getting an error message: "Missing selection for Parameter." How can I resolve this?&lt;/P&gt;&lt;P&gt;select * from table&amp;nbsp;&lt;/P&gt;&lt;P&gt;where country=:country&lt;/P&gt;&lt;P&gt;period=:period&lt;/P&gt;&lt;P&gt;Doc=:Document&lt;/P&gt;&lt;P&gt;If no value is entered for the 'Document' parameter, the query should retrieve all documents; otherwise, it should retrieve the value specified in the parameter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 10:22:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100580#M40339</guid>
      <dc:creator>techg</dc:creator>
      <dc:date>2024-12-02T10:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Missing selection for Parameter error</title>
      <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100627#M40358</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133987"&gt;@techg&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Could you try with below query?&lt;/P&gt;
&lt;P&gt;SELECT * FROM table&lt;BR /&gt;WHERE (:country IS NULL OR country = :country)&lt;BR /&gt;AND (:period IS NULL OR period = :period)&lt;BR /&gt;AND (:Document IS NULL OR Doc = :Document)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 13:40:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100627#M40358</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2024-12-02T13:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Missing selection for Parameter error</title>
      <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100704#M40382</link>
      <description>&lt;P&gt;Hi Alberto,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have tried the above mentioned changes in the SQL&amp;nbsp; query, but I'm still getting the same error "Missing Selection for Parameter error".&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 07:13:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100704#M40382</guid>
      <dc:creator>techg</dc:creator>
      <dc:date>2024-12-03T07:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Missing selection for Parameter error</title>
      <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100717#M40390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133987"&gt;@techg&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;For all the 3 parameters you need to create widgets.&lt;BR /&gt;The default should be the empty string&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CREATE WIDGET TEXT country DEFAULT '';
CREATE WIDGET TEXT period DEFAULT '';
CREATE WIDGET TEXT Document DEFAULT '';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You assign 2 values for country and period, leaving Document an empty string:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_0-1733213559743.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/13288i9E720FE09823975E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_0-1733213559743.png" alt="filipniziol_0-1733213559743.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The query:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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
  );&lt;/LI-CODE&gt;&lt;P&gt;Sample data:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;-- 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);&lt;/LI-CODE&gt;&lt;P&gt;The result of query on sample data:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_1-1733213659183.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/13289iF5F31337BEC45110/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_1-1733213659183.png" alt="filipniziol_1-1733213659183.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 08:18:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100717#M40390</guid>
      <dc:creator>filipniziol</dc:creator>
      <dc:date>2024-12-03T08:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Missing selection for Parameter error</title>
      <link>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100746#M40403</link>
      <description>&lt;P&gt;I'm creating this query with parameters in SQL Editor in Databricks and added it to the SQL Dashboard.&lt;/P&gt;&lt;P&gt;Do we need to create Widget while creating parameters in SQL Editor?&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i tried creating widget in SQL editor, Im getting syntax error near Widget SQLSTATE. Please advise&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 12:39:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/missing-selection-for-parameter-error/m-p/100746#M40403</guid>
      <dc:creator>techg</dc:creator>
      <dc:date>2024-12-03T12:39:47Z</dc:date>
    </item>
  </channel>
</rss>

