@gooddata/code-cli 0.50.0-alpha.5 → 0.50.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +45296 -20565
- package/dist/fixtures/rules/computedAttributes.mdc +51 -0
- package/dist/fixtures/rules/gooddata.mdc +1 -0
- package/dist/index.js +319 -16
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Detailed information about GoodData computed attributes definition.
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
# Fields
|
|
6
|
+
|
|
7
|
+
On top of generic fields like `id`, `type` (always "computed_attribute"), `title`, `description` and
|
|
8
|
+
`tags`, computed attributes support:
|
|
9
|
+
- `maql`: (string, required) a MAQL statement that assigns a group name to every row.
|
|
10
|
+
- `locale`: (string) a locale whose collation order the values are sorted by.
|
|
11
|
+
|
|
12
|
+
The `id` must be unique among computed attributes, and must not collide with the id of an attribute
|
|
13
|
+
or a label in the same workspace.
|
|
14
|
+
|
|
15
|
+
# What a computed attribute is
|
|
16
|
+
|
|
17
|
+
A computed attribute turns numbers into named groups - for example "Small", "Medium", "Large" - and
|
|
18
|
+
then behaves like any other attribute: it can be used to group a report, and it lives next to metrics
|
|
19
|
+
rather than in the data model.
|
|
20
|
+
|
|
21
|
+
# MAQL
|
|
22
|
+
|
|
23
|
+
Write the break points as a CASE expression over a metric. String values use double quotes, and the
|
|
24
|
+
first matching branch wins, so order the break points from the most specific one:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
SELECT CASE WHEN {metric/won_activities} > 100 THEN "High" WHEN {metric/won_activities} > 50 THEN "Mid" ELSE "Low" END
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Add a `BY` clause to pin the grain the metric is evaluated at. Without it the metric is evaluated in
|
|
31
|
+
whatever context the report slices by, so the group a row falls into would change with the report:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
SELECT CASE WHEN {metric/won_activities} > 100 THEN "High" ELSE "Low" END BY {label/sales_rep.name}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A computed attribute can be referenced from a metric, or from another computed attribute, under the
|
|
38
|
+
same `computed_attribute` type it is declared with:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
SELECT COUNT({computed_attribute/rep_performance})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
MAQL syntax is different from SQL. Do not try generating MAQL expressions based on SQL knowledge.
|
|
45
|
+
Instead, point user to GoodData documentation:
|
|
46
|
+
https://www.gooddata.com/docs/cloud/create-metrics/maql/
|
|
47
|
+
|
|
48
|
+
# Limits
|
|
49
|
+
|
|
50
|
+
Only break points the user writes out are supported. Groups by fixed count (histograms) and groups by
|
|
51
|
+
a fixed step are not.
|
|
@@ -37,5 +37,6 @@ A typical folder structure for GoodData analytics project looks like this:
|
|
|
37
37
|
- `{{ANALYTICS}}/datasets` - a folder with all datasets and date instances
|
|
38
38
|
- `{{ANALYTICS}}/metrics` - a folder with all metrics
|
|
39
39
|
- `{{ANALYTICS}}/parameters` - a folder with all parameters
|
|
40
|
+
- `{{ANALYTICS}}/computedAttributes` - a folder with all computed attributes
|
|
40
41
|
- `{{ANALYTICS}}/visualisations` - a folder with all visualizations
|
|
41
42
|
- `{{ANALYTICS}}/dashboards` - a folder with all dashboards
|