[英]How to filter a Line Chart with a Measure in Power BI?
I currently have a table in Power BI named Fruit
.我目前在 Power BI 中有一个名为
Fruit
的表。
Here is sample data from Fruit
:这是来自
Fruit
的示例数据:
Issue id![]() |
Label ![]() |
Label 1 ![]() |
Label 2 ![]() |
Label 3 ![]() |
Label 4 ![]() |
Created![]() |
Resolved![]() |
Time Difference (MINS)![]() |
---|---|---|---|---|---|---|---|---|
1000 ![]() |
Apples![]() |
Grapes![]() |
Bananas![]() |
Oranges![]() |
Strawberries![]() |
14/03/2021 11:38:23 ![]() |
11/02/2022 ![]() |
525632 ![]() |
1001 ![]() |
Oranges![]() |
Pears![]() |
Apples![]() |
Bananas![]() |
Strawberries![]() |
13/03/2021 12:34:34 ![]() |
18/03/2022 11:38:23 ![]() |
524324 ![]() |
1002 ![]() |
Pears![]() |
Dragon Fruit![]() |
Apples![]() |
Strawberries![]() |
Dragon Fruit![]() |
04/03/2021 18:31:11 ![]() |
12/03/2022 11:38:23 ![]() |
525345 ![]() |
1003 ![]() |
Bananas![]() |
Oranges![]() |
Apples![]() |
Grapes![]() |
Pears![]() |
11/03/2021 19:34:57 ![]() |
11/03/2022 11:38:23 ![]() |
528264 ![]() |
1004 ![]() |
Grapes![]() |
Apples![]() |
Bananas![]() |
Pears![]() |
Strawberries![]() |
12/03/2021 12:32:52 ![]() |
15/03/2022 11:38:23 ![]() |
521927 ![]() |
I have created a table to join the label values into one: AllLabel = SUMMARIZE(UNION(VALUES(Fruit[Label 1]), VALUES(Fruit[Label 2]), VALUES(Fruit[Label 3]), VALUES(Fruit[Label 4])),Fruit[Label 1])
我创建了一个表将 label 值合并为一个:
AllLabel = SUMMARIZE(UNION(VALUES(Fruit[Label 1]), VALUES(Fruit[Label 2]), VALUES(Fruit[Label 3]), VALUES(Fruit[Label 4])),Fruit[Label 1])
I also have created a measure count the labels and filter them uniquely: Apples
Oranges
Pears
Bananas
Strawberries
Dragon Fruit
Grapes
:我还创建了一个度量标签并对其进行唯一过滤:
Apples
Oranges
Pears
Bananas
Strawberries
Dragon Fruit
Grapes
:
SELECTEDFruit =
var _selectedFruit = SELECTEDVALUE(AllLabel[Label 1])
return
CALCULATE(COUNTROWS(Fruit) , FILTER(Fruit,Fruit[Label 1] = _selectedFruit || Fruit[Label 2] = _selectedFruit || Fruit[Label 3] = _selectedFruit || Fruit[Label 4] = _selectedFruit))
This is how the tables look:这是表格的外观:
I have a line chart to calculate the Average resolution time:我有一个折线图来计算平均解决时间:
However, when I choose a particular fruit using a slicer, it does not change the value of Average Resolution Time Line Chart.但是,当我使用切片机选择特定水果时,它不会更改平均分辨率时间线图的值。
How can I filter the Average Resolution Line Chart using the Label 1 slicer?如何使用 Label 1 切片器过滤平均分辨率折线图?
the reason is that your tables don't have relationships.原因是您的表没有关系。 make sure that there exist relationships between tables.
确保表之间存在关系。 it can be one relationship between two table,you should use dax Relationship functions such as USERELATIONSHIP formula for calculate between other columns.
它可以是两个表之间的一种关系,您应该使用dax关系函数,例如USERELATIONSHIP公式来计算其他列之间的关系。 however i recommend using pivot,unpivot and union dax function like in order to create another table to get best result from slicer and there will be no need for your dax formula AllLabel
但是我建议使用 pivot,unpivot 和 union dax function 之类的,以便创建另一个表以从切片器中获得最佳结果,并且不需要您的 dax 公式 AllLabel
UnpivotedTable= FILTER(
UNION(
SELECTCOLUMNS('Fruit',"Created",[Created],"Resolved",[Resolved],"Time Difference (MINS)",[Time Difference (MINS)],"label",[Label]),
SELECTCOLUMNS('Fruit',"Created",[Created],"Resolved",[Resolved],"Time Difference (MINS)",[Time Difference (MINS)],"label",[Label 1]),
SELECTCOLUMNS('Fruit',"Created",[Created],"Resolved",[Resolved],"Time Difference (MINS)",[Time Difference (MINS)],"label",[Label 2]),
SELECTCOLUMNS('Fruit',"Created",[Created],"Resolved",[Resolved],"Time Difference (MINS)",[Time Difference (MINS)],"label",[Label 3]),
SELECTCOLUMNS('Fruit',"Created",[Created],"Resolved",[Resolved],"Time Difference (MINS)",[Time Difference (MINS)],"label",[Label 4])),[Label]<>"")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.