如何根据年份使用动态名称来创建动态措施?

发布于 2025-02-05 09:28:58 字数 587 浏览 5 评论 0原文

目前,我在不同的几年中创建了一个度量MarketPrice以下几年:

marketprice 2021 = CALCULATE(LASTNONBLANKVALUE(table[column1],
                    SUMMARIZE(FILTER(table, table[year] = 2021), table[column1])))

marketprice 2022 = CALCUALTE(........)
marketprice 2023 = CALCUALTE(........)
marketprice 2024 = CALCUALTE(........)

但这不是动态的,因为明年(2023年)我只需要从2022,2023,2023,2024,2025年开始的市场价格(在DAX语法中:Year(loday()) - 1Year(today())YearS(today()()())+1年(today()())+2)。我不想每年更改措施计算中的量度名称和年份输入。

我希望这是可能的。

At the moment I create a measure marketprice for different years as the following:

marketprice 2021 = CALCULATE(LASTNONBLANKVALUE(table[column1],
                    SUMMARIZE(FILTER(table, table[year] = 2021), table[column1])))

marketprice 2022 = CALCUALTE(........)
marketprice 2023 = CALCUALTE(........)
marketprice 2024 = CALCUALTE(........)

But this is not dynamic because next year (2023) I only need the market prices from the years 2022, 2023, 2024, 2025 (in DAX syntax: YEAR(TODAY())-1, YEAR(TODAY()), YEAR(TODAY())+1, YEAR(TODAY())+2). I don't want to change every year the measure names and year-input in the measure calculation.

I hope this is possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神妖 2025-02-12 09:28:58

您不能创建动态度量名称,而是可以通过动态计算尝试一下: -

marketprice_previous_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) - 1 ),
            table[column1]
        )
    )
)


marketprice_current_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE ( FILTER ( table, table[year] = YEAR ( TODAY () ) ), table[column1] )
    )
)

marketprice_next_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) + 1 ),
            table[column1]
        )
    )
)

marketprice_next_to_next_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) + 2 ),
            table[column1]
        )
    )
)

You cant create dynamic name of measure instead you could try this with dynamic calculation:-

marketprice_previous_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) - 1 ),
            table[column1]
        )
    )
)


marketprice_current_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE ( FILTER ( table, table[year] = YEAR ( TODAY () ) ), table[column1] )
    )
)

marketprice_next_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) + 1 ),
            table[column1]
        )
    )
)

marketprice_next_to_next_year =
CALCULATE (
    LASTNONBLANKVALUE (
        table[column1],
        SUMMARIZE (
            FILTER ( table, table[year] = YEAR ( TODAY () ) + 2 ),
            table[column1]
        )
    )
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文