Skip to content

Commit 2daa102

Browse files
authored
docs(modeling): add format and type to dimensions reference (#6620)
1 parent be6562a commit 2daa102

File tree

2 files changed

+85
-13
lines changed

2 files changed

+85
-13
lines changed

docs/content/Schema/Reference/dimensions.mdx

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ redirect_from:
1111
---
1212

1313
The `dimensions` property contains a set of dimensions. You can think about a
14-
dimension as an attribute related to a measure, e.g. the measure `user_count` can
15-
have dimensions like `country`, `age`, `occupation`, etc.
14+
dimension as an attribute related to a measure, e.g. the measure `user_count`
15+
can have dimensions like `country`, `age`, `occupation`, etc.
1616

1717
Any dimension should have the following properties: `name`, `sql` and `type`.
1818

@@ -185,6 +185,43 @@ cubes:
185185
186186
</CodeTabs>
187187
188+
### <--{"id" : "Parameters"}--> format
189+
190+
`format` is an optional parameter. It is used to format the output of dimensions
191+
in different ways, for example, a link for `external_url`. Please refer to the
192+
[Dimension Formats][ref-schema-ref-dims-formats] for the full list of supported
193+
formats.
194+
195+
<CodeTabs>
196+
197+
```javascript
198+
cube(`orders`, {
199+
// ...
200+
201+
measures: {
202+
total: {
203+
sql: `amount`,
204+
type: `running_total`,
205+
format: `currency`,
206+
},
207+
},
208+
});
209+
```
210+
211+
```yaml
212+
cubes:
213+
- name: orders
214+
# ...
215+
216+
measures:
217+
- name: total
218+
sql: amount
219+
type: running_total
220+
format: currency
221+
```
222+
223+
</CodeTabs>
224+
188225
### <--{"id" : "Parameters"}--> meta
189226
190227
Custom metadata. Can be used to pass any information to the frontend.
@@ -348,9 +385,9 @@ cubes:
348385
### <--{"id" : "Parameters"}--> sql
349386
350387
`sql` is a required parameter. It can take any valid SQL expression depending on
351-
the `type` of the dimension. Please refer to the [Dimension Types
352-
Guide][ref-schema-ref-types-formats-dimension-types] for detailed information on
353-
the corresponding `sql` parameter.
388+
the `type` of the dimension. Please refer to the [Dimension
389+
Types][ref-schema-ref-dims-types] to understand what the `sql` parameter should
390+
be for a given dimension type.
354391

355392
<CodeTabs>
356393

@@ -451,9 +488,44 @@ cubes:
451488
452489
</CodeTabs>
453490
491+
### <--{"id" : "Parameters"}--> type
492+
493+
`type` is a required parameter. There are various types that can be assigned to
494+
a dimension. Please refer to the [Dimension Types][ref-schema-ref-dims-types]
495+
for the full list of dimension types.
496+
497+
<CodeTabs>
498+
499+
```javascript
500+
cube(`orders`, {
501+
// ...
502+
503+
dimensions: {
504+
rating: {
505+
sql: `rating`,
506+
type: `number`,
507+
},
508+
},
509+
});
510+
```
511+
512+
```yaml
513+
cubes:
514+
- name: orders
515+
# ...
516+
517+
dimensions:
518+
- name: rating
519+
sql: rating
520+
type: number
521+
```
522+
523+
</CodeTabs>
524+
454525
[ref-schema-ref-joins]: /schema/reference/joins
455-
[ref-schema-ref-types-formats-dimension-types]:
456-
/schema/reference/types-and-formats#dimensions-types
457526
[ref-subquery]: /schema/fundamentals/additional-concepts#subquery
458527
[self-subquery]: #sub-query
459528
[ref-naming]: /data-modeling/syntax#naming
529+
[ref-schema-ref-dims-types]: /schema/reference/types-and-formats#dimension-types
530+
[ref-schema-ref-dims-formats]:
531+
/schema/reference/types-and-formats#dimension-formats

docs/content/Schema/Reference/measures.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ cubes:
184184
185185
`format` is an optional parameter. It is used to format the output of measures
186186
in different ways, for example, as currency for `revenue`. Please refer to the
187-
[Measure Formats Guide][ref-schema-ref-types-formats-measures-formats] for the
188-
full list of supported formats.
187+
[Measure Formats][ref-schema-ref-types-formats-measures-formats] for the full
188+
list of supported formats.
189189

190190
<CodeTabs>
191191

@@ -461,8 +461,8 @@ cubes:
461461
### <--{"id" : "Parameters"}--> type
462462
463463
`type` is a required parameter. There are various types that can be assigned to
464-
a measure. Please refer to the [Measure Types
465-
Guide][ref-schema-ref-types-formats-measures-types] for the full list of measure
464+
a measure. Please refer to the [Measure
465+
Types][ref-schema-ref-types-formats-measures-types] for the full list of measure
466466
types.
467467

468468
<CodeTabs>
@@ -533,8 +533,8 @@ You can create calculated measures from several joined cubes. In this case, a
533533
join will be created automatically.
534534
535535
[ref-schema-ref-types-formats-measures-types]:
536-
/schema/reference/types-and-formats#measures-types
536+
/schema/reference/types-and-formats#measure-types
537537
[ref-schema-ref-types-formats-measures-formats]:
538-
/schema/reference/types-and-formats#measures-formats
538+
/schema/reference/types-and-formats#measure-formats
539539
[ref-drilldowns]: /schema/fundamentals/additional-concepts#drilldowns
540540
[ref-naming]: /data-modeling/syntax#naming

0 commit comments

Comments
 (0)