【问题标题】:get all dates dim table which between the start and end date of fact table in fact table获取事实表中事实表的开始日期和结束日期之间的所有日期暗表
【发布时间】:2021-12-14 00:38:45
【问题描述】:

我有两张桌子。
事实:

Date Value
2021-10-21 1
2021-10-23 2
2021-10-26 3

昏暗:

Date
2021-10-19
2021-10-20
2021-10-21
2021-10-22
2021-10-23
2021-10-24
2021-10-25
2021-10-26
2021-10-27
2021-10-28

fact_start_date = minx(all(Fact), Fact[Date])
fact_end_date = maxx(all(Fact), Fact[Date])

我想在 Fact 表中编写度量,结果如下表。
ِDim table Dates 介于 Fact 表的 fact_start_datefact_end_date 之间,空值替换为零。

注意事项:
1.在事实表中写入度量
2.使用度量,而不是新表

结果:
(从昏暗中选择日期)

Date measure
2021-10-21 1
2021-10-22 0
2021-10-23 2
2021-10-24 0
2021-10-25 0
2021-10-26 3

谢谢

【问题讨论】:

  • 使用度量(非计算列)SumOfValues = SUM('Fact'[Value])+0 并过滤日期工作正常吗?如果没有过滤器,它将为 Dim 中所有不在的值显示 0,如果需要,这也可以通过代码完成
  • 感谢您的回答。所以对。公式IF(ISBLANK(SUM(FactFunds[Value])), 0, SUM(FactFunds[Value])) 也可以将空格归零。但我想自动过滤暗淡的日期。

标签: dax powerbi-desktop powerpivot daxstudio


【解决方案1】:

我对公式SUMX (VALUES(Dim[Date]), IF (Dim[Date] <= fact_end_date && Dim[Date] >= fact_start_date, SUM(Fact[Value]) + 0)) 进行了很多尝试,但没有得到正确的答案。 公式正确。问题是Dim表和Fact表之间的关系(交叉过滤器方向)Both。当我将其更改为 Single 时,公式已正确实现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-14
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多