cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

AI/BI Dashboard metric views: cross-filter returns no rows when value contains CRLF

Akash_Murade
New Contributor III

Summary

In an AI/BI Dashboard with a semantic model, selecting a row in a table widget cross-filters a related table through the relationship. This works for normal values. When the selected row has a text value containing a carriage return followed by a line feed (CRLF), the related table returns no rows, even though matching data exists. Values with only CR or only LF filter correctly.

Steps to reproduce

  • Create a dashboard with two datasets defined as metric views:
# Id and Title
version: '1.1'
source: |-
  SELECT 1 AS id, 'Alpha' AS title
  UNION ALL SELECT 2, 'Beta'
  UNION ALL SELECT 3, 'Gamma'
dimensions:
  - name: id
    expr: id
  - name: title
    expr: title
# Id and Comments
version: '1.1'
source: |-
  SELECT 1 AS id, 'Plain single-line comment' AS comments
  UNION ALL SELECT 2, concat('First line of the comment', chr(13), chr(10), 'Second line after the carriage return and newline')
  UNION ALL SELECT 3, 'Another single-line comment'
dimensions:
  - name: id
    expr: id
  - name: comments
    expr: comments
  • Add a one-to-many relationship from Id and Comments to Id and Title, on `Id and Comments.id = Id and Title.id`.
  • Add table widget โ€œParentโ€ on Id and Comments: id, comments.
  • Add table widget โ€œChildโ€ on Id and Title: id, title.
  • Click row 1 or 3 in Parent. Child filters to the matching row.
  • Click row 2 (the comment contains CRLF). Child returns no rows.

Expected behavior

Selecting row 2 filters Child to id 2 (Beta), the same as for the other rows.

Actual behavior

Child returns no rows. The generated visualization query applies this filter in the metric view:

filter: "(`Id_and_Comments_SQL`.`id` IN (2) AND `Id_and_Comments_SQL`.`comments` IN ('First line of the comment\r\nSecond line after the carriage return and newline')) AND (...same condition repeated...)"

The filter on comments does not match the stored value.

Additional observations

  1. If the value contains only CR (chr(13)) or only LF (chr(10)), the cross-filter works. It only fails when both appear together as CRLF.
  2. The filter condition appears twice in the generated query.

Impact

Text columns from source systems (e.g. comments or descriptions from ERP data) often contain CRLF line breaks. Clicking such a row shows an empty related table, which looks like thereโ€™s no related data rather than a filter failure.

Workaround

Remove line breaks in the dataset, e.g. `translate(comments, chr(13) || chr(10), ' ')`.

Environment

Databricks AI/BI Dashboards with metric view datasets and a semantic model relationship.

1 REPLY 1

suranga
Databricks Partner

Hi @Akash_Murade,

Thanks for the clean repro, it makes this really easy to follow. It looks like a bug in how the selected value gets turned into the filter literal, so I'd raise it with Databricks support as well so it gets tracked properly.

Until it's fixed, you can keep the line breaks instead of flattening them to a space. Since LF-only values filter fine in your tests, normalise CRLF to LF in the metric view dimension:

dimensions:
  - name: id
    expr: id
  - name: comments
    expr: replace(comments, chr(13) || chr(10), chr(10))

The table widget still shows the comment on two lines, and the cross-filter matches again because the generated filter is applied to that same expression. Using chr() also avoids any doubt about how \r\n escapes get handled between the YAML and the SQL.

If you'd rather not change the dimension itself, the same replace() works in the metric view's source query.

Cheers,
Suranga