简体   繁体   English

基于所选筛选值的同一表中的行值之间的差异 - Power BI

[英]Variance between row values in same table based on selected filter values - Power BI

I am trying to return the variance values between rows based off of multiple filter values.我正在尝试根据多个过滤器值返回行之间的方差值。

Data set looks like this:数据集如下所示:

Bid Name投标名称 Service Area服务区 Task Name任务名称 Resource资源 Hours小时 Revenue收入
Bid 1投标 1 SA1 SA1 Fix the lights修好灯 R1 R1 75 75 100 100
Bid 2投标 2 SA1 SA1 Fix the lights修好灯 R1 R1 100 100 175 175

What I am looking for, is something like this:我正在寻找的是这样的:

Slicer 1切片机 1
Bid 1 (selected)投标 1(选定)
Bid 2投标 2
Slicer 2切片机 2
Bid 1投标 1
Bid 2 (selected)投标 2(选定)
Service Area服务区 Task Name任务名称 Resource资源 Hours小时 Revenue收入
SA1 SA1 Fix the lights修好灯 R1 R1 25 25 75 75

I have tried a lot of variations using calculate and all selected and tried copying the table and using one slicer on table 1 and the other on table 2. A few nuances:我尝试了很多变体,使用计算并全部选择并尝试复制表并在表 1 上使用一个切片器,在表 2 上使用另一个切片器。一些细微差别:

  1. I need the table to return only rows where there are variances我需要表格只返回有差异的行
  2. If the same bid is selected in both slicers, the values should return nothing (as there should be no variances如果在两个切片器中选择了相同的出价,则值不应返回任何值(因为不应有差异

If there is a better way to do this without the slicers I am fine to do it without.如果没有切片机有更好的方法可以做到这一点,我可以不用切片机。

Any help is greatly appreciated.任何帮助是极大的赞赏。

You'll need to create a separate table for each slicer and neither of these slicer tables should be related to your data table or each other.您需要为每个切片器创建一个单独的表,并且这些切片器表都不应该与您的数据表或彼此相关。

That is, two calculated tables即两个计算表

Slicer1 = VALUES ( Data[Bid Name] )
Slicer2 = VALUES ( Data[Bid Name] )

Then you write a measure that reads the slicers and calculates the difference (and returns a blank if the difference is zero).然后编写一个读取切片器并计算差异的度量(如果差异为零,则返回空白)。

HourDiff =
VAR Bid1 = SELECTEDVALUE ( Slicer1[Bid Name] )
VAR Bid2 = SELECTEDVALUE ( Slicer2[Bid Name] )
VAR Hours1 = CALCULATE ( SUM ( Data[Hours] ), Data[Bid Name] = Bid1 )
VAR Hours2 = CALCULATE ( SUM ( Data[Hours] ), Data[Bid Name] = Bid2 )
RETURN
    IF (
        ISBLANK ( Hours1 ) || ISBLANK ( Hours2 ) || Hours1 = Hours2,
        BLANK(),
        Hours2 - Hours1
    )

The measure for RevenueDiff is analogous. RevenueDiff的度量是类似的。

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

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