cube-js / cube-js/cube

Power BI Error When Recreating Conditional Flag Logic Outside Cube.js Model (PostgreSQL Connector, Databricks Backend)

Open
#10,028 1 comment 0 reactions 1 assignee Claimed by @igorlukanin View on GitHub
api:sql question tool:power-bi
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

Summary:
I'm using Cube.js as a semantic layer over Databricks, and connecting Power BI via the PostgreSQL connector. I’ve defined a conditional flag (customerRegionFlag) in the Customers cube using a case block. When this logic is defined inside the Cube.js model, it works perfectly — even when combined with measures from the Orders cube.

However, when I recreate the same logic in Power BI (e.g., using DAX or query editor), and combine it with a measure like totalAmount, I get the following error:

Error Message:
```
OLE DB or ODBC error: [DataSource.Error] PostgreSQL: XX000: Arrow error: Compute error: Unable to map value Number(-167142707430404.1) to Decimal(38, 10).
```

Model Setup:

Orders cube: contains totalAmount measure.
Customers cube: joined via customer_id, contains customerRegionFlag defined as:

```js
customerRegionFlag: {
type: `number`,
case: {
when: [
{ sql: `${CUBE}.region = 'North'`, label: `1` }
],
else: { label: `0` }
}
}
```
Observations:

The logic works when defined in Cube.js and used in Power BI visuals with measures.
The error occurs only when recreating the same logic in Power BI, not in the model.
Both fields are numeric; no type mismatch.
The error seems related to how Power BI processes the combined result outside Cube.js.

Is there a known limitation when recreating Cube.js logic in Power BI using the PostgreSQL connector?
Should all conditional logic be defined in the Cube.js model to avoid such errors?
Any recommended workaround or best practices?

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.