问题描述
我有一个计算,我只想返回最左边的值,即第一次满足条件。
在图像中它显示95%,96%等,等等,我只关心满足95的条件的第5列。 / p>
编辑(更多信息)
确定,因此百分比是用这种方式计算的。
ROUND(RUNNING_SUM(SUM([days_to_close_cnt]))/ SUM([newo_dt_cnt]),2)
使用,结束日为我提供了列信息。
线形图看起来像这样。
如果[完成百分比]> = .98并且[完成百分比]< 1,然后INT(98)
elseif [完成百分比] = 1,然后INT(1)
elseif [完成百分比]≥.95并且[完成百分比]≤1。 .98,则INT(95)
elseif [完成百分比]< .95和[已完成的百分比]> = .0,然后INT(0)
结束
在这种情况下是我用来着色的calc吗?
您似乎正在尝试判断运行总计何时超过阈值。在Tableau中,这样做需要对从数据源返回的聚合值进行运算的表计算。
我将来说明如何解决此问题。
在通过上面的链接的实时版本中,请尝试将鼠标悬停在某些数据点上以查看详细的工具提示,并逐步增加阈值以查看计算的行为。您还可以单击表格选项卡以查看一些中间结果。
这是静态快照,以防您无法访问上面链接的动态快照。
简而言之,您可以定义一个计算的布尔值字段来判断特定日期的运行总计是否达到阈值,然后使用window_min()计算满足阈值的第一天。有关更多详细信息,请下载工作簿并查看计算出的字段以了解其工作原理。
表计算功能强大,但Tableau中的功能也是使用率最高的功能是时候动手了。因此,请分解并一小部分解决它们,而不是尝试一次编写所有复杂的表计算。幸运的是,在大多数情况下都有捷径(快速表计算)。请注意,为表calc指定分区和寻址字段(即,使用计算)与编写公式一样重要。
最后,计算字段可以更有效地写为:
,如果[完成百分比]< .95,然后0
elseif [已完成百分比]< .98,然后是95
elseif [已完成百分比]< 1然后98 98
否则1
结束
I have a calculation, and I only want to return the left most value ie, the first time the condition is met.
In the images it shows 95% 96% etc etc I only care for the column 5 where the condition of 95 is met.
EDIT(more info)
Ok so the percentages are calculated this way.
ROUND( RUNNING_SUM( SUM( [days_to_close_cnt] ) )/ SUM([newo_dt_cnt]),2 )
Using and the "Days to Close" gives me the column information.
The Line graph looks like this.
if [% Completed] >= .98 and [% Completed] < 1 then INT( 98 )
elseif [% Completed] = 1 then INT( 1 )
elseif [% Completed] >= .95 and [% Completed] < .98 then INT( 95 )
elseif [% Completed] < .95 and [% Completed] >= .0 then INT( 0 )
end
Is that calc I am using to color in this case.
It looks like you are trying to tell when a running total crosses a threshold. In Tableau, doing that requires table calculations which operate on the aggregated values that have been returned from the data source.
I put together an example viz to illustrate how to approach the issue.
In the live version via the link above, try hovering over some of the data points to see the tooltips for detail, and incrementally increasing the threshold to see how the calculation behaves. You can also click on the table tab to see some of the intermediate results.
Here's a static snapshot in case you can't access the dynamic one linked above
In a nutshell, you can define a boolean calculated field to tell whether the running total meets the threshold on a particular day and then use window_min() to calculate the first day that meets the threshold. For more detail, download the workbook and check out the calculated fields to understand how it works.
Table calcs are powerful, but are also the feature in Tableau that takes the most time to get your head around. So break things down and tackle them in small bites instead of trying to write complex table calcs all at once. Luckily, there are short cuts (quick table calcs) for the most common cases. Be aware that specifying the partitioning and addressing fields (i.e., compute using) for a table calc is as important as writing the formula.
Finally as an aside, your calculated field can be written more efficiently as:
if [% Completed] < .95 then 0
elseif [% Completed] < .98 then 95
elseif [% Completed] < 1 then 98
else 1
end
这篇关于第一次满足返回值条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!