按日期排名使用DAX

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

Ranking by date using DAX

问题

我有一个表格,看起来像这样:

按日期排名使用DAX

我已经开发了以下公式来解决这个问题:

RANK____ = 
RANKX (
    FILTER ( 'tableName', 'tableName'[Disease] = EARLIER('tableName'[Disease])),
    'tableName'[Released Date],
    ASC,
    DENSE
)

我遇到的问题是显示以下错误消息:“EARLIER/EARLIEST 引用了一个不存在的先前行上下文。”

在我的分析中没有先前的筛选上下文。我错过了什么?请记住,最终用户将需要选择他们感兴趣的任何药物,并查看该药物首次发布时用于哪种疾病。

英文:

I have a table that looks like this:

按日期排名使用DAX

I have developed the following formula to solve this solution:

RANK____ = 
RANKX (
    FILTER ( 'tableName', 'tableName'[Disease] = EARLIER('tableName'[Disease'])),
    'tableName'[Released Date],
    ,
    ASC,
    DENSE
)

The issue I am having is that is showing the following error message: "EARLIER/EARLIEST refers to an earlier row context which doesn't exist."

There is no previous filter context in my analysis. What am I missing? Keep in mind that the final user would have to select any drug they are interested in and see for which disease that drug was first released.

答案1

得分: 1

你这里不需要使用RANKX函数,可以使用RANK函数。类似这样:

RANK____ = RANK(DENSE,,ORDERBY([Released Date],ASC),,PARTITIONBY('tableName'[Disease]))

你期望的输出表明你想按药物分区而不是疾病。如果确实要按药物分区,只需将PARTITIONBY()子句更改为PARTITIONBY('tableName'[Drug])。

错误消息:“EARLIER/EARLIEST引用了不存在的先前行上下文”,说明问题所在。要使EARLIER函数起作用,需要存在一个先前的行上下文,但这里没有。

英文:

You don't need the RANKX function here. You can use the RANK function.
Something like this:

RANK____ = RANK(DENSE,,ORDERBY([Released Date],ASC),,PARTITIONBY('tableName'[Disease]))

Your desired output suggests that you want to partition by drug and not disease. If you indeed want to partition by drug, just change the PARTITIONBY() clause to PARTITIONBY('tableName'[Drug]).

The error message: "EARLIER/EARLIEST refers to an earlier row context which doesn't exist.", speeks for itself. For the EARLIER function to work, there needs to be an earlier row context and there isn't one.

huangapple
  • 本文由 发表于 2023年6月30日 03:04:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583961.html
匿名

发表评论

匿名网友

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

确定