从 PowerBI 中的现有表创建单独的表

问题描述 投票:0回答:1

我认为这是一个简单的问题,我只是不知道如何去做。在PowerBI中,我以下面的例子为例,这是两个时间序列':

日期 系列1 系列2
1-5 月 0.650239 0.994032
5月2日 0.689518 0.457408
5月3日 0.969402 0.863187
4-5 月 0.812362 0.547719
5月 0.760445 0.717409
5 月 6 日 0.342214 0.091408
5 月 7 日 0.985581 0.066404
5 月 8 日 0.236865 0.507268
5 月 9 日 0.744359 0.803286
5 月 10 日 0.470509 0.221594
11-5 月 0.487833 0.648442
5 月 12 日 0.541049 0.143225
5 月 13 日 0.041194 0.335399
14-5 月 0.191586 0.951685

正如我试图证明的那样,这两个系列都在同一个表中。我想做的就是创建一个单独的表,其中包括每个系列的最新值和平均值,如下所示:

最新 平均
系列1 0.191586 0.56594
系列2 0.951685 0.52489

我尝试在 PowerQuery 中进行旋转和取消旋转,但似乎无法将其设置为正确的格式。有人可以建议如何创建单独的表吗?我最初认为我必须为每个计算创建一个单独的度量,但即使如此,也无法弄清楚如何根据我想要实现的目标进行格式化。非常感谢。

powerbi
1个回答
0
投票

这将向您的模型添加两个以上的表,但它有效。 首先,您需要将表取消透视为新表。 然后使用以下代码创建新表:

    TableSummarized =
SUMMARIZE (
    'TableUnpivot',
    'TableUnpivot'[Attribute],
    "Latest",
        CALCULATE (
            AVERAGE ( 'TableUnpivot'[Value] ),
            'TableUnpivot'[Date] = MAX ( 'TableUnpivot'[Date] )
        ),
    "Average", AVERAGE ( 'TableUnpivot'[Value] )
)

结果是:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.