Default value in sql

Hi,

Need help if the below query is the correct syntax for complex default value

AND Year=[[{{Year}} --]] year(GETDATE())

If this is set, I can put in the default value on the filter, however if the filter is chosen with a value

The error below will be thrown

Maybe using COALESCEhere will help but i need help on the syntax for it. Thanks

Hi @zhenghao
Without knowing which database type you are querying, then it's difficult to know the comment syntax:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#setting-complex-default-values-in-the-query

Post "Diagnostic Info" from Admin > Troubleshooting.

Hi,

Using MSSQL.

@zhenghao I don't know which filter type you are using.

  1. Post "Diagnostic Info" from Admin > Troubleshooting
  2. Post the detailed stacktrace error from Admin > Troubleshooting > Logs
  3. Post a full screenshot showing the Variables sidebar