简体   繁体   English

powerBI或powerpivot中的关系过滤器

[英]relationship filter in powerBI or powerpivot

i am using the powerBI tools (powerpivot) to create a data model. 我正在使用powerBI工具(powerpivot)创建数据模型。 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. 现在,我需要显示所有带来产品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 例如,客户A带来了产品1和产品5,而该客户的总收入为50,因此我想显示50

customer B bought product 4 and i do not want to include this customer in my output. 客户B购买了产品4,而我不想在输出中包括该客户。

i can do the same in microstratergy using relationship filter but how can i do the same in powerpivot or powerview or powerBI. 我可以使用关系过滤器在微层战略中做同样的事情,但是我如何在powerpivot或powerview或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). 在PowerPivot中,将“销售”表与“客户”表(“查找”表)关联,并将“销售”表与“产品”表(“查找”表)相关。
  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. 在ROWS中选择客户,然后在VALUES中添加[DesiredMeasure],数据透视表将显示所需的结果。

Additionally to what Abhijeet said, which is a nice robust solution, you might also just filter the chart in Power View. 除了Abhijeet所说的那样,这是一个很好的健壮解决方案,您也可以只在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. 假设您在销售表和产品表之间有关系,则可以在Power View中选择图表,打开“筛选器”窗格,选择每个图表筛选器,将“产品”添加到图表筛选器,然后筛选仅包含生产1,2,3。 This will automatically calculate the measure. 这将自动计算度量。 Now Abhijeet's solution is better if you need that calculation to be reused. 现在,如果您需要重新使用该计算,Abhijeet的解决方案会更好。 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.". 如果您想在“假设情况”中说“ 1,2,3产品的销售量是多少”,而在另一口气中说“实际上我对产品的销售感兴趣”,那么该解决方案将非常有用仅2,3,所以我改为。”。

HTH, -Lukasz HTH-卢卡斯

http://dev.powerbi.com http://dev.powerbi.com

http://blogs.msdn.com/powerbidev http://blogs.msdn.com/powerbidev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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