forked from looker/block-gcp-billing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcp_billing_export_credits_core.view.lkml
52 lines (42 loc) · 1.58 KB
/
gcp_billing_export_credits_core.view.lkml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
include: "//@{CONFIG_PROJECT_NAME}/gcp_billing_export.view"
view: gcp_billing_export_credits {
extends: [gcp_billing_export_credits_config]
}
view: gcp_billing_export_credits_core {
### Field description reference https://cloud.google.com/billing/docs/how-to/export-data-bigquery
### DIMENSIONS
dimension: credit_id {
primary_key: yes
hidden: yes
sql: CONCAT(CAST(${gcp_billing_export.pk} as STRING), COALESCE(${credit_name}, "0")) ;;
}
dimension: credit_amount {
group_label: "Credits"
description: "Amount of credit given to billing account (always negative)"
type: number
sql: ${TABLE}.amount ;;
}
dimension: credit_name {
group_label: "Credits"
description: "Name of the credit applied to account"
type: string
sql: ${TABLE}.name ;;
}
### MEASURES
measure: total_credit {
description: "The total credit given to billing account (always negative)"
type: sum
sql: ${credit_amount} ;;
value_format_name: decimal_2
html: {% if gcp_billing_export.currency._value == 'GBP' %}
<a href="{{ link }}"> £{{ rendered_value }}</a>
{% elsif gcp_billing_export.currency == 'USD' %}
<a href="{{ link }}"> ${{ rendered_value }}</a>
{% elsif gcp_billing_export.currency == 'EUR' %}
<a href="{{ link }}"> €{{ rendered_value }}</a>
{% else %}
<a href="{{ link }}"> {{ rendered_value }} {{ gcp_billing_export.currency._value }}</a>
{% endif %} ;;
drill_fields: [gcp_billing_export_credits.credit_name,gcp_billing_export_credits.credit_amount]
}
}