cube-js / cube-js/cube

Measure behaves different in power bi then in playground

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

Description

I created a measure to calculate an average of my sales.

This is my cube

```javascript
cube(`bug_order`, {
sql: ` select 1 as "id", 100 as "amount", 1 as "fk_status"
UNION ALL
select 2 as "id", 200 as "amount", 1 as "fk_status"
UNION ALL
select 3 as "id", 300 as "amount", 1 as "fk_status"
UNION ALL
select 4 as "id", 500 as "amount", 2 as "fk_status"
UNION ALL
select 5 as "id", 600 as "amount", 3 as "fk_status"
`,
public: true,
joins: {
bug_order_status: {
sql: `${CUBE}."fk_status" = ${bug_order_status}."id"`,
relationship: `many_to_one`
},

},

dimensions: {
id: {
sql: `${CUBE}."id"`,
type: `number`,
primary_key: true
},

amount: {
sql: `${CUBE}."amount"`,
type: `number`
},

fk_status: {
sql: `${CUBE}."fk_status"`,
type: `string`,
format: 'id'
}
}
,
measures: {
countOrdersNew: {
sql: `${CUBE}."id"`,
type: `count`,
filters: [
{ sql: `${bug_order_status.status} = 'new'` }
]
},
avgSales: {
sql: `${CUBE}."amount"`,
type: `avg`
}
}});
```

but when I connect this cube to a view and connect that view into power bi, power bi does not recognize the measure as an average.

this is the code for my view:

```javascript
view(`RecreateBug`, {
public: true,
cubes: [
{
join_path: bug_order,
includes: `*`
},
{
join_path: bug_order.bug_order_status,
includes: '*',
excludes: [
`id`
]
}

]
});
````

But when I import this view in power bi it want to sum it.

![image](https://github.com/user-attachments/assets/32c9e6b1-a8d3-498d-9a8e-bec5a2d6b342)
![image](https://github.com/user-attachments/assets/520886e7-bb80-4da6-a67a-cd833bff14aa)

Am I doing something wrong?

Kind regards,
Antony

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.