DAX度量在尝试引用日历表时出了什么问题?

huangapple go评论68阅读模式
英文:

what is wrong with DAX measure when trying to reference a calendar table

问题

我有一个名为“Date”的日历表,其中包含过去3年每一天的不同日期。

我还有一个名为“Treatments”的表,其中包含SessionID、Treatment Date和Treatment Status,看起来像这样。

DAX度量在尝试引用日历表时出了什么问题?

我正在尝试在日历表(该表名为Date)中添加一个新列,该列计算过去30天每天的“Completed” Treatments数量。

我有以下DAX Measure

Completed Treatments =
CALCULATE(
COUNTROWS(Treatments),
Treatments[Treatment Status] = "Completed",
DATESBETWEEN(
Treatments[Treatment Date],
MAX(Date[Date]) - 30,
MAX(Date[Date])))

但我一直收到“[Date]”的语法错误。有人知道发生了什么吗?

英文:

I've got a calendar table called "Date", which contains a distinct date for every day of the the past 3 years.

I also got a "Treatments" table, which contains a SessionID, Treatment Date and a Treatment Status, it looks something like this.

DAX度量在尝试引用日历表时出了什么问题?

What I am trying to do, is add a new column in the Calendar table (This table is called Date) that counts the amount of "Completed" Treatments for each day for the past 30 days.

I've got the following DAX Measure

Completed Treatments = 
CALCULATE(
    COUNTROWS(Treatments),
    Treatments[Treatment Status] = "Completed",
    DATESBETWEEN(
        Treatments[Treatment Date],
        MAX(Date[Date]) - 30,
        MAX(Date[Date])))

but I keep getting an error of "The syntax for '[Date]' is incorrect.

Does anybody know what is going on?

答案1

得分: 1

只需为日期表添加 '

Completed Treatments = 
CALCULATE(
    COUNTROWS(Treatments),
    Treatments[Treatment Status] = "Completed",
    DATESBETWEEN(
        Treatments[Treatment Date],
        MAX('Date'[Date]) - 30,
        MAX('Date'[Date])))

DAX度量在尝试引用日历表时出了什么问题?

英文:

Just add ' for Date table.

Completed Treatments = 
CALCULATE(
    COUNTROWS(Treatments),
    Treatments[Treatment Status] = "Completed",
    DATESBETWEEN(
        Treatments[Treatment Date],
        MAX('Date'[Date]) - 30,
        MAX('Date'[Date])))

DAX度量在尝试引用日历表时出了什么问题?

huangapple
  • 本文由 发表于 2023年7月13日 18:27:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定