Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ cube(`users`, {
},

purchases_to_users_ratio: {
sql: `100.0 * ${orders.purchases} / ${CUBE.count}`,
sql: `1.0 * ${orders.purchases} / ${CUBE.count}`,
type: `number`,
format: `percent`
}
Expand Down
2 changes: 1 addition & 1 deletion docs-mintlify/docs/data-modeling/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ measure via an API, the following SQL will be generated:

```sql
SELECT
100.0 * COUNT(
1.0 * COUNT(
CASE WHEN (users.paying = 'true') THEN users.id END
) / COUNT(users.id) AS paying_percentage
FROM users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ within the `measures` block.
```yaml
- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down Expand Up @@ -156,7 +156,7 @@ cubes:

- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down
4 changes: 2 additions & 2 deletions docs-mintlify/recipes/data-modeling/cohort-retention.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ cubes:
- users.email

- name: percentage_of_active
sql: "100.0 * {total_active_count} / NULLIF({total_count}, 0)"
sql: "1.0 * {total_active_count} / NULLIF({total_count}, 0)"
type: number
format: percent
drill_members:
Expand Down Expand Up @@ -168,7 +168,7 @@ cube(`monthly_retention`, {
},

percentage_of_active: {
sql: `100.0 * ${total_active_count} / NULLIF(${total_count}, 0)`,
sql: `1.0 * ${total_active_count} / NULLIF(${total_count}, 0)`,
type: `number`,
format: `percent`,
drill_members: [
Expand Down
8 changes: 4 additions & 4 deletions docs-mintlify/recipes/data-modeling/event-analytics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ cubes:
- - sql: "{is_bounced} = 'True'

- name: bounce_rate
sql: "100.00 * {bounced_count} / NULLIF({count}, 0)"
sql: "1.0 * {bounced_count} / NULLIF({count}, 0)"
type: number
format: percent
```
Expand Down Expand Up @@ -770,7 +770,7 @@ cube("sessions", {
},

bounce_rate: {
sql: `100.00 * ${bounced_count} / NULLIF(${count}, 0)`,
sql: `1.0 * ${bounced_count} / NULLIF(${count}, 0)`,
type: `number`,
format: `percent`
}
Expand Down Expand Up @@ -846,7 +846,7 @@ cube("sessions", {

repeat_percent: {
description: `Percent of Repeat Sessions`,
sql: `100.00 * ${repeat_count} / NULLIF(${count}, 0)`,
sql: `1.0 * ${repeat_count} / NULLIF(${count}, 0)`,
type: `number`,
format: `percent`
}
Expand Down Expand Up @@ -875,7 +875,7 @@ cubes:

- name: repeat_percent
description: Percent of Repeat Sessions
sql: "100.00 * {repeat_count} / NULLIF({count}, 0)"
sql: "1.0 * {repeat_count} / NULLIF({count}, 0)"
type: number
format: percent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const createPercentageMeasure = (status) => ({
sql: (CUBE) =>
`ROUND(${CUBE[`total_${status}_orders`]}::NUMERIC / ${
CUBE.total_orders
}::NUMERIC * 100.0, 2)`
}::NUMERIC, 2)`
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ cubes:

- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ cubes:

- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ cube(`users`, {
},

purchases_to_users_ratio: {
sql: `100.0 * ${orders.purchases} / ${CUBE.count}`,
sql: `1.0 * ${orders.purchases} / ${CUBE.count}`,
type: `number`,
format: `percent`
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/product/data-modeling/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ measure via an API, the following SQL will be generated:

```sql
SELECT
100.0 * COUNT(
1.0 * COUNT(
CASE WHEN (users.paying = 'true') THEN users.id END
) / COUNT(users.id) AS paying_percentage
FROM users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ cubes:
- users.email

- name: percentage_of_active
sql: "100.0 * {total_active_count} / NULLIF({total_count}, 0)"
sql: "1.0 * {total_active_count} / NULLIF({total_count}, 0)"
type: number
format: percent
drill_members:
Expand Down Expand Up @@ -168,7 +168,7 @@ cube(`monthly_retention`, {
},

percentage_of_active: {
sql: `100.0 * ${total_active_count} / NULLIF(${total_count}, 0)`,
sql: `1.0 * ${total_active_count} / NULLIF(${total_count}, 0)`,
type: `number`,
format: `percent`,
drill_members: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ cube("sessions", {
},

bounce_rate: {
sql: `100.00 * ${bounced_count} / NULLIF(${count}, 0)`,
sql: `1.0 * ${bounced_count} / NULLIF(${count}, 0)`,
type: `number`,
format: `percent`
}
Expand Down Expand Up @@ -770,7 +770,7 @@ cubes:
- - sql: "{is_bounced} = 'True'

- name: bounce_rate
sql: "100.00 * {bounced_count} / NULLIF({count}, 0)"
sql: "1.0 * {bounced_count} / NULLIF({count}, 0)"
type: number
format: percent
```
Expand Down Expand Up @@ -843,7 +843,7 @@ cube("sessions", {

repeat_percent: {
description: `Percent of Repeat Sessions`,
sql: `100.00 * ${repeat_count} / NULLIF(${count}, 0)`,
sql: `1.0 * ${repeat_count} / NULLIF(${count}, 0)`,
type: `number`,
format: `percent`
}
Expand Down Expand Up @@ -872,7 +872,7 @@ cubes:

- name: repeat_percent
description: Percent of Repeat Sessions
sql: "100.00 * {repeat_count} / NULLIF({count}, 0)"
sql: "1.0 * {repeat_count} / NULLIF({count}, 0)"
type: number
format: percent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const createPercentageMeasure = (status) => ({
sql: (CUBE) =>
`ROUND(${CUBE[`total_${status}_orders`]}::NUMERIC / ${
CUBE.total_orders
}::NUMERIC * 100.0, 2)`
}::NUMERIC, 2)`
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ within the `measures` block.
```yaml
- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down Expand Up @@ -154,7 +154,7 @@ cubes:

- name: completed_percentage
type: number
sql: "(100.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
sql: "(1.0 * {CUBE.completed_count} / NULLIF({CUBE.count}, 0))"
format: percent
```

Expand Down
2 changes: 1 addition & 1 deletion examples/recipes/active-users/schema/ActiveUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cube(`ActiveUsers`, {

wauToMau: {
title: `WAU to MAU`,
sql: `100.000 * ${weeklyActiveUsers} / NULLIF(${monthlyActiveUsers}, 0)`,
sql: `1.0 * ${weeklyActiveUsers} / NULLIF(${monthlyActiveUsers}, 0)`,
type: `number`,
format: `percent`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const createPercentageMeasure = (status) => ({
format: `percent`,
title: `Percentage of ${status} orders`,
sql: (CUBE) =>
`ROUND(${CUBE[`Total_${status}_orders`]}::numeric / ${CUBE.totalOrders}::numeric * 100.0, 2)`,
`ROUND(${CUBE[`Total_${status}_orders`]}::numeric / ${CUBE.totalOrders}::numeric, 2)`,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ${eventJoin.join('\nLEFT JOIN\n')}
shown: false
},
conversionsPercent: {
sql: (conversions, firstStepConversions) => `CASE WHEN ${firstStepConversions} > 0 THEN 100.0 * ${conversions} / ${firstStepConversions} ELSE NULL END`,
sql: (conversions, firstStepConversions) => `CASE WHEN ${firstStepConversions} > 0 THEN 1.0 * ${conversions} / ${firstStepConversions} ELSE NULL END`,
type: 'number',
format: 'percent'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cubes:
- sql: "{CUBE}.status = 'completed'"

- name: completed_percentage
sql: "({completed_count} / NULLIF({count}, 0)) * 100.0"
sql: "1.0 * {completed_count} / NULLIF({count}, 0)"
type: number
format: percent

Expand Down
Loading