代码之家  ›  专栏  ›  技术社区  ›  p.ganesh kumar

如何在DAX中编写此逻辑?

  •  0
  • p.ganesh kumar  · 技术社区  · 7 年前

    我想在我的表中添加一个新列 [lastmonth] .我想要上个财政月TPH的值与上个月的值进行比较 projectid 或分组依据 项目ID

    请在DAX查询中给出此逻辑。

    This image contains output which we are expecting.

    2 回复  |  直到 7 年前
        1
  •  0
  •   Alexis Olson    7 年前

    尝试将其作为新的计算列:

    Last Fiscal Month =
        MAXX(
            FILTER(Table1,
                Table1[projectid] = EARLIER(Table1[projectid]) &&
                Table1[TPH] <> 0),
            Table1[Fiscal Month])
    
        2
  •  0
  •   ibarrau    7 年前

    您可以在DAX中尝试此新列

    Last Fiscal =
    MAXX (
        FILTER (
            SELECTCOLUMNS (
                Table,
                "ProjId", Table[projectid],
                "FMonth", Table[Fiscal Month],
                "The TPH", Table[TPH]
            ),
            [The TPH] <> 0
                && [ProjId] = Table[projectid]
        ),
        [FMonth]
    )
    

    当做

    推荐文章