简体   繁体   English

如何在 Power BI 中添加度量过滤器?

[英]how to add filter on measure in power BI?

I have Power BI report having some filters implemented on columns.我有 Power BI 报告,其中在列上实现了一些过滤器。 Now I have to add a new filter on the basis of measure, I have data in the following format for that column, +ve integer , -ve integer or 0 .现在我必须在度量的基础上添加一个新的过滤器,我有该列的以下格式的数据, +ve integer-ve integer0 What I'm trying to achieve, there should be a filter with three default values ( +ve integers , -ve integers and 0 ).我想要实现的是,应该有一个带有三个默认值( +ve integers-ve integers0 )的过滤器。 When I select +ve , it should show only records having +ve integer values and so on for two other cases.当我选择+ve ,它应该只显示具有+ve整数值的记录等其他两种情况。

Problem: I am creating measure from a measure but not getting the exact data from it.问题:我正在从一个度量创建度量,但没有从中获取确切的数据。

The second thing I did was created a measure of positive and negative, I am getting the exact data if I will use in table visual but not in the slicers form.我做的第二件事是创建了一个正负度量,如果我将在表格视觉中使用而不是在切片器形式中使用,我将获得确切的数据。

Measures are not meant to be used as slicers.度量不打算用作切片器。 A best practice for Power BI is that if you need to filter by a certain criteria then you should create a new column in the data to reflect which values you want to filter by. Power BI 的最佳做法是,如果您需要按特定条件进行筛选,则应在数据中创建一个新列以反映要作为筛选依据的值。

If you have a very large data set then I would do this in the Query Editor using a conditional column.如果您有一个非常大的数据集,那么我将使用条件列在查询编辑器中执行此操作。 在此处输入图片说明

If you size isn't a factor then make a calculated column like so,如果您的大小不是一个因素,那么像这样制作一个计算列,

Answer =
SWITCH (
    TRUE (),
    'Table'[Values] > 0, "Postive",
    'Table'[Values] < 0, "Negative",
    "Zero"
)

Now insert the column into the filter and you should be able to easily switch between what you need.现在将列插入过滤器,您应该能够轻松地在所需内容之间切换。

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

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