【问题标题】:How to create a cumulative sum over two columns with comlementary Date Range in Power BI如何在 Power BI 中创建具有互补日期范围的两列的累积总和
【发布时间】:2021-03-03 08:57:13
【问题描述】:

我正在尝试构建一个折线图来显示预测的累积总和。我有两张表,一张用于实际数据,一张用于预测,两者都链接到日期表。该图表应显示截至本月和下个月的实际实际值的累积总和,这些总和来自预测。 到目前为止,我已经创建了以下措施来获取预测图表:

Chart_Forecast not cumulated = 
VAR Actual_Hrs_not_cumulated = CALCULATE([Total Actuals],FILTER(IN_ACTUALS, IN_ACTUALS[Date] <= MAX(CurrentMonth[CurrentMonthParameter])))
VAR Forecast_not_cumulated = CALCULATE([Total Forecast],FILTER(IN_Forecast, IN_Forecast[Date] > MAX(CurrentMonth[CurrentMonthParameter])))
RETURN
IF((SELECTEDVALUE('LT_Reporting Calendar'[Date]) <= MAX(CurrentMonth[CurrentMonthParameter])),Actual_Hrs_not_cummulated, Forecast_not_Cumulated)

这个给了我非累积预测的折线图,它有效。

但是一旦我想根据下面的度量在上面的度量上建立累积总和,我只会得到当前月份的累积总和,而未来会被省略。我想我有一个过滤器问题。 我尝试了许多建立累积和的方法,总是得到相同的结果。

Chart_Forcast Cumulated = 
CALCULATE(
    [Chart_Forecast not cumulated],
    FILTER(
        ALL('LT_Reporting Calendar'[Date]),
        'LT_Reporting Calendar'[Date] <= MAX ('LT_Reporting Calendar'[Date])
    )
)

输入:

结果:图表 有没有人对此有想法?

提前致谢

【问题讨论】:

  • 您能否展示您正在使用的数据以及您期望的最终结果?
  • 数据已添加。谢谢
  • 请将您的数据添加为格式化文本而不是图像。

标签: powerbi


【解决方案1】:

我建议把它写成这样的总和:

Cumulative =
VAR ParameterDate = SELECTEDVALUE ( CurrentMonth[CurrentMonthParameter] )
VAR AxisDate = SELECTEDVALUE ( 'LT_Reporting Calendar'[Date] )
RETURN
    CALCULATE (
        [Total Actuals],
        'LT_Reporting Calendar'[Date] <= AxisDate,
        'LT_Reporting Calendar'[Date] <= ParameterDate
    ) +
    CALCULATE (
        [Total Forecast],
        'LT_Reporting Calendar'[Date] <= AxisDate,
        'LT_Reporting Calendar'[Date] > ParameterDate
    )

【讨论】:

  • 嗨,亚历克西斯,你太棒了,它有效。纳夫尊重。非常感谢
猜你喜欢
  • 2018-01-16
  • 2020-10-16
  • 2020-07-30
  • 2022-11-07
  • 1970-01-01
  • 2018-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多