代码之家  ›  专栏  ›  技术社区  ›  Adhitya Sanusi

为特定字段添加行号

  •  1
  • Adhitya Sanusi  · 技术社区  · 8 年前

    我有以下SQL数据。

    DOB         Status       Policy StartDate   EndDate
    1/05/1983   Lapsed       P1     5/05/2015   5/06/2016
    1/05/1983   New Business P2     3/05/2016   
    2/04/1999   Lapsed       P3     5/02/2016   10/06/2017
    2/04/1999   New Business P4     10/07/2017  
    3/06/1972   Lapsed       P5     6/07/2016   15/12/2017
    3/06/1972   New Business P6     1/10/2017   
    4/12/1954   Lapsed       P7     7/03/2017   1/03/2018
    4/12/1954   New Business P8     1/03/2018   
    

    我需要根据DOB字段添加降序数。预期结果如下所示。

    enter image description here

    不幸的是,我只能得到列#中的数字“1”。

    对于列#,我尝试使用index()、Window\u Count(Countd(DOB),04,0)、Runnning\u Total(Table Down、Pane Down、Specific Dimension:DOB),但没有任何效果。

    我正在使用Tableau桌面/服务器10.0。

    谢谢大家的帮助。

    1 回复  |  直到 8 年前
        1
  •  2
  •   Armin    8 年前

    使用 RANK_DENSE 功能:

    “返回分区中当前行的密集秩。相同的值被指定为相同的秩,但不会在数字序列中插入间隙。使用可选的‘asc’|‘desc’参数指定升序或降序。默认值为降序。

    使用此函数,将对值集(6、9、9、14)进行排序(3、2、2、1)。“”

    RANK_DENSE(SUM(FLOAT([DOB])),'asc')
    

    enter image description here