@@ -426,9 +426,107 @@ Using it with other dimension types will result in a validation error.
426426
427427</Info >
428428
429+ ### ` links `
430+
431+ The ` links ` parameter allows you to define links associated with a dimension.
432+ They can be rendered as HTML links by supporting tools, e.g., [ Workbooks] [ ref-workbooks ] .
433+
434+ Links are useful to let users navigate to related external resources (e.g., Google
435+ search), internal tools (e.g., Salesforce), or other pages in a BI tool.
436+
437+ Each link must have a ` name ` and a ` label ` . The ` name ` is used as an identifier
438+ in the [ synthetic dimension] ( #synthetic ) name.
439+
440+ A link must specify either a ` url ` or a ` dashboard ` :
441+ - ` url ` is a SQL expression that constructs the link URL. It can [ reference] [ ref-references ]
442+ column and dimension values, just like the [ ` sql ` parameter] ( #sql ) or [ ` mask ` parameter] ( #mask ) .
443+ - ` dashboard ` is a dashboard identifier. When set, the link URL is generated as
444+ ` /dashboard/<dashboard_id> ` . The ` params ` object is still appended as a query string.
445+
446+ Optionally, a link might use the ` icon ` parameter to reference an icon from a [ supported
447+ icon set] [ link-tabler ] to be displayed alongside the link label.
448+
449+ Optionally, a link might use the ` target ` parameter to specify [ where to open it] [ link-target ] :
450+ ` blank ` (default) to open in a new tab/window or ` self ` to open in the same tab/window.
451+
452+ ``` yaml
453+ cubes :
454+ - name : users
455+
456+ dimensions :
457+ # Definitions of dimensions such as `email`, etc.
458+
459+ - name : full_name
460+ sql : full_name
461+ type : string
462+ links :
463+ - name : google_search
464+ label : Search on Google
465+ url : " CONCAT('https://www.google.com/search?q=', {CUBE}.full_name)"
466+ icon : brand-google
467+ target : blank
468+
469+ - name : salesforce_search
470+ label : Search in Salesforce
471+ url : " CONCAT('https://your-company.salesforce.com/search/results/?q=', {email})"
472+ target : blank
473+
474+ - name : send_email
475+ label : Write an email
476+ url : " CONCAT('mailto:', {email})"
477+ icon : send
478+ ` ` `
479+
480+ #### ` params`
481+
482+ The optional `params` parameter can be used to add additional query parameters to the
483+ URL. It accepts a map of key-value pairs, where keys are parameter names and values are
484+ SQL expressions (just like `url`).
485+
486+ Values in `params` can [reference][ref-references] columns and dimension values.
487+ All parameter values will be [URL-encoded][link-encode-uri-component] in the generated SQL
488+ using a database-specific encoding function.
489+
490+ ` ` ` yaml
491+ cubes:
492+ - name: users
493+
494+ dimensions:
495+ # Definitions of dimensions such as ` id`, `country`, etc.
496+
497+ - name : full_name
498+ sql : full_name
499+ type : string
500+ links :
501+ - name : performance
502+ label : Check performance dashboard
503+ dashboard : KSqDYdUz6Ble
504+ params :
505+ - key : filter_user_id
506+ value : " {id}"
507+ - key : filter_country
508+ value : " {country}"
509+ ` ` `
510+
511+ #### Synthetic dimensions
512+
513+ Each link will be rendered as an additional [synthetic](#synthetic) dimension in the
514+ result set, with the following naming convention:
515+
516+ - ` <dimension_name>___link_<link_name>_url`
517+
518+ <Info>
519+
520+ All references in link URLs and parameters must resolve to a single value for a given
521+ value of the dimension on which the link is defined. Otherwise, it will result in
522+ duplicate rows in the result set.
523+
524+ </Info>
525+
429526# ## `meta`
430527
431- Custom metadata. Can be used to pass any information to the frontend.
528+ The `meta` parameter allows you to attach arbitrary information to a dimension.
529+ It can be consumed and interpreted by supporting tools.
432530
433531You can also use the `ai_context` key to provide context to the
434532[AI agent][ref-ai-context] without exposing it in the user interface.
@@ -902,6 +1000,13 @@ cube(`orders`, {
9021000
9031001</CodeGroup >
9041002
1003+ ### ` synthetic `
1004+
1005+ The ` synthetic ` parameter can't be set by a user directly. It is used to mark dimensions
1006+ that are automatically created by Cube, e.g., for [ links] ( #links ) .
1007+
1008+ You can check if a dimension is synthetic via the [ ` /v1/meta ` API endpoint] [ ref-meta-api ] .
1009+
9051010### ` granularities `
9061011
9071012By default, the following granularities are available for time dimensions:
@@ -1222,4 +1327,11 @@ cube(`fiscal_calendar`, {
12221327[ link-tesseract ] : https://cube.dev/blog/introducing-next-generation-data-modeling-engine
12231328[ ref-case-measures ] : /reference/data-modeling/measures#case
12241329[ ref-meta-api ] : /reference/rest-api/reference#base_pathv1meta
1225- [ ref-string-time-dims ] : /recipes/data-modeling/string-time-dimensions
1330+ [ ref-string-time-dims ] : /recipes/data-modeling/string-time-dimensions
1331+ [ ref-workbooks ] : /docs/explore-analyze/workbooks
1332+ [ link-target ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#target
1333+ [ link-tabler ] : https://tabler.io/icons
1334+ [ ref-references ] : /docs/data-modeling/syntax#references
1335+ [ ref-filter-params ] : /reference/data-modeling/context-variables#filter_params
1336+ [ link-encode-uri-component ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
1337+ [ ref-rest-filters ] : /reference/rest-api/query-format#query-properties
0 commit comments