简体   繁体   中英

relationship filter in powerBI or powerpivot

i am using the powerBI tools (powerpivot) to create a data model. i am done the model. the model include the product, customer dimensions and sales fact table. i have made the relationship and hierarchy in the model. now i have a requirement to show the total revenue of all the customer who brought product 1,2,3.

for example customer A brought product 1 and product 5 and the total revenue from this customer is 50 so i want to show 50 as a result

customer B bought product 4 and i do not want to include this customer in my output.

i can do the same in microstratergy using relationship filter but how can i do the same in powerpivot or powerview or powerBI.

Please help Thanks in Advance

  1. In PowerPivot, relate Sales table with Customer table (Lookup table) and Relate Sales table to Product table (Lookup table).
  2. Create following two measures

     [HasPurchased X Products] = OR ( OR ( CONTAINS ( Sales, Sales[ProductID], 1 ), CONTAINS ( Sales, Sales[ProductID], 3 ) ), CONTAINS ( Sales, Sales[ProductID], 5 ) ) [DesiredMeasure] = IF ( Sales[HasPurchased X Products] = TRUE (), SUM ( [Amount] ), BLANK () ) 
  3. Select Customers in ROWS and add [DesiredMeasure] in VALUES, pivot table will show desired result.

Additionally to what Abhijeet said, which is a nice robust solution, you might also just filter the chart in Power View. Assuming you have a relationship between sales and products table, you can select the chart in Power View, open the Filters pane, select per chart filters, add Product to the chart filters and filter to include only productions 1,2,3. This will automatically calculate the measure. Now Abhijeet's solution is better if you need that calculation to be reused. This solution works great if you're in a 'what if' scenario where you'd like to say "what are the sales for products 1,2,3" and in another breath say "actually i'm interested in sales for products 2,3 only, so me that instead.".

HTH, -Lukasz

http://dev.powerbi.com

http://blogs.msdn.com/powerbidev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM