简体   繁体   English

DAX与Power BI中的其他人一起衡量Top N

[英]DAX Measure Top N with others in Power BI

I'm developing a report in Power BI where i need to show the Top N Countries by the value of some Produkts they produce. 我正在Power BI中开发一份报告,在该报告中,我需要按其生产的某些产品的价值来显示前N个国家/地区。

I already managed it to calculate the Top N countries which are variable, but I have no idea how to sum the "Others" in there. 我已经设法计算出变量最高的N个国家,但是我不知道如何对其中的“其他”进行求和。
So i need eg the Top 5 plus "Others" in the stacked Bar Chart. 因此,我需要堆积条形图中的前5个加“其他”。
Unfortunately I can't add a measure in the legend field, so I need a workaround for that. 不幸的是,我无法在图例字段中添加度量,因此我需要一种解决方法。

You have to add an "Other" country in your countries table, since you cannot add a country or group of countries dynamically. 您必须在国家表中添加“其他”国家/地区,因为您不能动态添加国家或国家/地区组。

First you have to create a rank measure. 首先,您必须创建排名度量。

Sales Rank=RANKX(ALL(Data[Country]),[Sales]) 

Use the rank measure to determine how to sum the measure you want to show. 使用等级度量来确定如何对要显示的度量求和。

Top3:=IF ([Sales Rank] <= 3,[Total],
  IF(HASONEVALUE(Data[Country]),
    IF(VALUES(Data[Country]) = "Others",
       SUMX ( FILTER ( ALL ( Data[Country] ), [Sales Rank] > 3 ), [Total] )
    ) 
  ) 
)

Check this answer I posted in other question. 检查我在其他问题中发布的答案

Let me know if this helps. 让我知道是否有帮助。

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

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