Forum Discussion
abhiram342
Microsoft Employee
6 years agoRankX function across multiple Dimension Tables
Hi All, I have two dimension tables and one fact table . I have Product Table (Dimension) , Customer Table ( Dimesnion) and Sales table (Fact). For Each Product, I would like display Top 3 Custo...
Anonymous
6 years agoNot applicable
// Create a measure that for each
// customer will tell you if
// they are in the top 3 cust for
// a product or not. Then use the measure
// as a filter for a table visual that will
// show you the existing combinations
// of Product and Customer and will display
// the [Total Sales] measure. Filter the
// visual by [Filtering Measure] = 1.
[Filtering Measure] =
var __oneProductAndCustomerVisible =
HASONEVALUE( Customer[CustID] )
&& HASONEVALUE( Product[ProdID] )
var __result =
if(
__oneProductAndCustomerVisible,
var __top3Customers =
CALCULATE(
// Bear in mind that if there
// are ties with respect to
// [Total Sales], all the qualified
// customers will be returned, so
// there might be more than 3.
topn(3,
VALUES( Customer[CustId] ),
[Total Sales],
DESC
),
ALL( Customer )
)
var __currentCustInTop3 =
VALUES( Customer[CustID] )
in __top3Customers
return
1 * __currentCustInTop3
)
return
__result- abhiram3426 years ago
Microsoft Employee
Thanks daxer ! I'm gettng error in below part of code.
Funciton expects table expression for argument but string was used
var __currentCustInTop3 =
VALUES( Customer[CustID] )
in __top3CustomersThanks,
Abhiram