简体   繁体   English

如何根据使用Power BI的选择将Filter添加到Slicer以显示计算的度量

[英]How to add Filter to Slicer to display the calculated Measure based on selection using Power BI

I am totally new to Power BI and struggling with Slicer. 我对Power BI完全陌生,并且正努力与Slicer合作。 I have the below requirement: 我有以下要求:

I have 4 columns Starting From, Destination, Distance KM. 我有4列起点,目的地,距离KM。 For this, I need to add a slicer. 为此,我需要添加一个切片器。 If the user clicks on Distance KM, then the chart has to be updated with Distance KM values. 如果用户单击“距离KM”,则必须使用“距离KM”值更新图表。 Now here comes the trick. 现在来了把戏。 I also want to display a column Distance in Miles based on the Distance KM calculation(the KM has to be displayed in Miles). 我还想根据距离KM计算显示一列距离(以英里为单位)(KM必须以英里为单位显示)。 So, whenever user clicks on Distance KM(in slicer), it should show the chart with KM data, if the user clicks on Miles(in slicer), then the chart should be populated with Miles information. 因此,每当用户单击“距离KM”(在切片器中)时,都应显示带有KM数据的图表,如果用户单击“英里”(在切片器中),则应在图表中填充“英里”信息。 I need to do this using slicer in power bi. 我需要在功率bi中使用切片器来执行此操作。 Trying to achieve this since a while but couldn't get through it. 试图实现这一目标已经有一段时间了,但无法实现。

Please help me out 请帮帮我

You only list three columns after stating your data has four, but I believe this should work: 在说明数据有四列之后,您仅列出三列,但是我认为这应该可行:

You need to create a new table for the slicer. 您需要为切片器创建一个新表。 Within the Home tab select "Enter Data". 在“主页”选项卡中,选择“输入数据”。 Enter the values you want to be able to select from (I named the table DistanceSlicer). 输入您想要选择的值(我将其命名为“ DistanceSlicer”表)。 Load that table and create a slicer with it. 加载该表并使用它创建切片器。

在此处输入图片说明

Now you can create a new measure based on this slicer selection. 现在,您可以基于此切片器选择创建一个新度量。 Within the Modeling tab select "New Measure". 在“建模”选项卡中,选择“新度量”。

SelectedMeasure =
IF (
    VALUES ( DistanceSlicer[Measure] ) = "Kilometers",
    SUM ( Table1[Distance KM] ),
    SUM ( Table1[Distance Miles] )
)

Now use this measure in your table/chart and it should update based on your slicer selection. 现在,在您的表/图表中使用此度量,它应该根据切片器的选择进行更新。

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

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