需要 Power Bi 功能 DATEADD 的建议

发布于 2025-01-10 06:10:13 字数 133 浏览 3 评论 0原文

我怎样才能创建这样的测量: 如果 email_name = '1' 则向 some_value 添加 4 天,如果 email_name = '2' 则向 some_value 添加 4 天。

所以我认为这个想法很明确。 对不起我的英语。

How can i create mesure like that:
If email_name = '1' add 4 days to some_value , If email_name = '2' to some_value.

So i think the idea is clear.
Sorry for my English.

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

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

发布评论

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

评论(1

对你的占有欲 2025-01-17 06:10:13

因为我想您想要逐行执行 IF 条件,所以创建计算列而不是度量会更好。无论如何,计算列的 DAX 看起来像这样:

New Col =
SWITCH(
    [email_name],
    '1', [some_date_value] + 4,
    '2', [some_date_value] + ?, // Your statement was not clear here...
    <value to return in all other cases here>
)

我在这里建议使用 SWITCH 语句,以避免构建嵌套 IF 语句的麻烦。请记住,您的 [some_date_value] 列需要是日期或数字的数据类型,以便 Power BI 可以添加天数。

Because I imagine you are wanting to do an IF condition row-by-row, you'd be much better served by creating a calculated column as opposed to a measure. In any case, your DAX for the calculated column would look something like this:

New Col =
SWITCH(
    [email_name],
    '1', [some_date_value] + 4,
    '2', [some_date_value] + ?, // Your statement was not clear here...
    <value to return in all other cases here>
)

I recommend a SWITCH statement here so as to aviod the nuisance of building nested IF statements. Keep in mind that your [some_date_value] column will need to be the data type of date or numeric so that Power BI can add the days.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文