Forum Discussion

jameshoneywill's avatar
jameshoneywill
Frequent Visitor
3 years ago

Measure creating relationship issues / duplicate rows in table

Hi 

I have 3x dimension tables; dim_Customer, dim_Business, dim_Product
(dim_Business is a list of offices)
1x fact table; fact_sales
all three dimension tables relate to 3 different fields in fact_sales

I have a fully working measure - [billed_revenue]

When I produce a table with the columns; 'Office name, Customer name, billed_revenue', then everything works

I then need to create a 'gap analysis' of whether a customer is currently buying a specific product, is an ex-customer of it, or has never bought the product. 

I have this measure which works perfectly in the table but only with the columns from dim_customer (i.e. customer name, [gap apples]) when I bring in the Office name I get a row for every office name against each customer name. i.e. I have 5 office names in dim_Business and get 5 rows for every Customer name. 

I don't understand how the first measure can work and yet when used in the below measure it doesn't...
note - MAXDate is a calculated column in fact_sales

GAP Apples =

if ( CALCULATE(
[Billed Revenue],
FILTER(fact_Sales,
 fact_Sales[Period] = fact_Sales[MaxDate]), FILTER(dim_product,
dim_product[Product Name] = "Apples"))

> 0,
"Yes",
if ( CALCULATE(
[Billed Revenue],
FILTER(dim_product,
dim_product[Product Name] = "Apples"))
 > 0, "Lost",
"Never"
))




4 Replies