cube-js / cube-js/cube

Switch dimension and multi-stage measure not working if dimension is not selected

Open
#10,661 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
To handle multiple currencies we would like to use a switch dimension for the currencies we support and a multi-stage measure picking from the dimension. This works when we filter on the switch dimension but if it's left out it will not show our default currency but it will show "number of currencies" rows instead.
We are using Clickhouse as the database

**To Reproduce**
Steps to reproduce the behavior:

```yaml
- name: dynamic_amount
type: number
multi_stage: true
case:
switch: ${currency_selector}
when:
- value: 'EUR'
sql: "{amount_eur}"
- value: 'NOK'
sql: "{amount_nok}"
- value: 'USD'
sql: "{amount_usd}"
else:
sql: '{amount_usd}'
title: Dynamic Amount
```

and a dimension
```yaml
- name: currency_selector
type: switch
values:
- USD
- EUR
- NOK
```

**Expected behavior**
When leaving the filter out on the currency_selector I'd expect it to show the column as in USD.

**Version:**
Cube Store version 1.6.10
Latest docker image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.