如何在 Tableau 中将一段时间内的累积总计值转换为实际每日值?

发布于 2025-01-18 13:09:20 字数 166 浏览 4 评论 0原文

我正在处理累积数据集,需要将累积值转换为同一列的每日值。 我通过创建计算字段来做到这一点,但是第一行的值丢失了。因为第一行没有前一行。我需要以一种让第一行拥有自己的值的方式编写代码。 我的代码是这样的:

ZN(SUM([地面武器总数])) - LOOKUP(ZN(SUM([地面武器总数])), -1)

I am working on a cumulative dataset and I need to convert cumulative values to daily values of the same column.
I did it with creating a calculated field, but, the first row's value is missed. Because there is no previous row for the first row. I need to write the code in a way that lets the first row by it's own value.
my Code is this :

ZN(SUM([Total Ground Weapons])) - LOOKUP(ZN(SUM([Total Ground Weapons])), -1)

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

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

发布评论

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

评论(1

日久见人心 2025-01-25 13:09:20

Samkart 大致上倾向于正确的方向,尽管我可能会使用使用 Index() 而不是 First() 的逻辑语句 First(

)、Last() 和 Index() 都是行排序器:

  • Index() 枚举自0 对分区中的每个记录递增 1
  • First() 从 0 开始枚举,对每个记录递减 1
  • Last() 是奇数,从集合中的最后一条记录开始为 0,然后递增 1直到到达集合中的第一条记录,例如集合中的 17 行,Last() 将以 0 开始,递增 1,在第一条记录上计数到 16

因此,对于您的计算,我将测试:

If Index() = 1 Then Sum(0)
Else Zn(Sum([Total Ground Weapons])) - Lookup(Zn(Sum([Total Ground Weapons])), -1)
End

这样,您将能够为集合中的第一个条目定义一个值。

史蒂夫

Samkart is broadly leaning in the correct direction, though I'd probably go with a logic statement that utilises Index() rather than First()

First(), Last() and Index() are all row sequencers:

  • Index() enumerates from 0 incrementing by 1 for each record in the partition
  • First() enumerates from 0 decrement by 1 for each record
  • Last() is an odd one, beginning the very last record in the set as 0 and then incrementing by 1 until you reach the first record in the set eg 17 rows in the set, Last() would begin as 0 incrementing by 1 counting to 16 on the first record

So for your calculation I'd test:

If Index() = 1 Then Sum(0)
Else Zn(Sum([Total Ground Weapons])) - Lookup(Zn(Sum([Total Ground Weapons])), -1)
End

This way, you'll be able to define a value for the first entry in your set.

Steve

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