如何在Power BI中创建后续措施

时间:2019-07-02 15:33:38

标签: powerbi average dax measure

我正在尝试创建三个连续的度量。在这种情况下,我有两个层次的分组查找最大值,然后是我希望具有平均值的第三分组层次。这是一种措施,因为我需要能够对聚合的输入进行切片。

我是Power BI的新手,所以我可能没有正确编写语法。我已经尝试过averagex,summary,groupby等的各种迭代。

非常感谢所有帮助!

以下是我正在处理的数据的示例:

<ListView x:Name="TargetListView" Grid.Row="2" Grid.Column="1" Margin="8,4" AllowDrop="True" CanDragItems="True" CanReorderItems="True" DragItemsCompleted="TargetListView_DragItemsCompleted" DragItemsStarting="TargetListView_DragItemsStarting" DragOver="TargetListView_DragOver" Drop="TargetListView_Drop" > <ListView.Footer> <Border Background="DarkGray" Opacity="0.8"> <TextBlock x:Name="Footer" Height="44" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="25" Text="Please Place your item" TextAlignment="Center" Visibility="Collapsed" /> </Border> </ListView.Footer> </ListView> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="DragDropGroup"> <VisualState x:Name="Outside" /> <VisualState x:Name="Inside"> <VisualState.Setters> <Setter Target="Footer.Visibility" Value="Visible" /> </VisualState.Setters> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups>

我想采取三种措施:

Name   uniqueID    Equipment_Number    Failure_Mode    Rating
A       A1          A1A                 Succcess        1
A       A1          A1A                 Low             2
A       A1          A1B                 Succcess        1
A       A1          A1B                 Success         1
A       A2          A2A                 Succcess        1
A       A2          A2A                 High            4
A       A2          A2B                 High            4
A       A2          A2B                 High            4
B B1 B1A Succcess 1 B B1 B1A Succcess 1 B B1 B1B Succcess 1 B B1 B1B High 4 B B2 B2A Low 2 B B2 B2A Success 1 B B2 B2B Medium 3 B B2 B2B Low 2

1 个答案:

答案 0 :(得分:1)

这是因为定义变量时,它是一个固定值。即__Module_Rating_Measure是固定的。

然后,您的第二个VAR__System_Rating_Measure给出相同的常数,因为要最大化的每个值都是相同的固定值。平均值一样。

尝试将这些VAR部分定义为单独的量度,而不是将其定义为与变量相同的量度。

另一种选择是使用SUMMARIZE来构建表变量而不是标量变量。

有关更多详细信息,将有助于编辑问题以提供示例数据和所需结果。


编辑:我看不出有任何理由两次获得最高奖励。只需在uniqueID级别取一次最大值,然后取平均值:

Average =
AVERAGEX (
    VALUES ( Table1[uniqueID] ),
    CALCULATE (
        MAX ( Table1[Rating] ),
        Table1[uniqueID] = EARLIER ( Table1[uniqueID] )
    )
)

这会遍历当前过滤器上下文中的每个uniqueID值,并计算该ID的最大值Rating,然后取平均值。

AvgMax

相关问题