在附加查询上使用运行总计的可视化问题

问题描述

使用PowerBI链接到两个单独的访问数据库

我有两个包含成本估算的数据集。数据集1中的成本估算持续到2054年;数据集2中的成本估算将运行到2074年。我使用了Append函数将两个表连接在一起,并使用了“运行总计”快速度量来创建按年累积成本的值。我绘制了此度量的图表,并注意到2054年至2055年之间的显着下降,并且能够确定该下降是数据集1的累积值。有人知道有什么方法可以解决此问题吗?

粗略解释:

Dataset 1 through 2054 totals to 4.5M.
Dataset 2 through 2054 totals to 3M
Dataset 2 through 2055 totals to 3.25M
Appended Dataset through 2054 totals to 7.5M
Appended Dataset through 2055 totals 3.25M instead of the expected 7.75M

我认为此问题可能是由于数据集1没有2055或更高的值引起的,但是我不确定如何解决此问题。

我正在使用的度量是:

Cumulative Cost = 
CALculaTE(
    SUM('AppendedQuery'[Value]),FILTER(
        ALLSELECTED('AppendedQuery'[Year]),ISOnorAFTER('AppendedQuery'[Year],MAX('AppendedQuery'[Year]),DESC)
    )
)

ETA: Picture to explain

解决方法

这是您的数据集1 -

enter image description here

这是您的数据集2 -

enter image description here

这是附加数据集1和2后的最终数据集

enter image description here

最后,这是将“年份”和“累计成本”列添加到表视觉中时的输出。作为标准的PBI行为,这只是使用“年份”列对数据进行分组,然后将“总和”应用于“累计费用”列。

enter image description here

计算很简单-

2051 > 1 + 1 = 2
2052 > 2 + 2 = 4
2053 > 3 + 3 = 6
2054 > 4 + 4 = 8
2055 >     5 = 5
2056 >     6 = 6

========================

您的案例的解决方案: 我已经在评论中说过,解决方案当前的数据将不是标准数据,并且将考虑每个部门每年固定的$ 1。但是,如果您对此静态考虑感到满意,则可以应用以下步骤来实现所需的输出-

步骤1 ,如下所示创建自定义列(根据您的表名进行调整)-

this_year_spent = IF('Dataset 3'[Cumulative Cost] = BLANK(),1)

步骤2 创建以下 Measure-

cumulative = 

VAR current_year = MIN('Dataset 3'[Year])

RETURN
CALCULATE(
    SUM('Dataset 3'[this_year_spent]),FILTER(
        ALL('Dataset 3'),'Dataset 3'[Year] <= current_year
    )
)

这是最终输出-

enter image description here