[英]Spotfire: Filtering table to get one record from each group
I have the following table:我有下表:
UWI![]() |
FORM![]() |
SOURCE![]() |
MD![]() |
---|---|---|---|
123 ![]() |
BRAIDED![]() |
DRR![]() |
100 ![]() |
123 ![]() |
BRAIDED![]() |
ERK ![]() |
150 ![]() |
123 ![]() |
BRAIDED![]() |
KPB ![]() |
200 ![]() |
123 ![]() |
TUSCHER![]() |
DRR![]() |
300 ![]() |
123 ![]() |
TUSCHER![]() |
MDB![]() |
350 ![]() |
123 ![]() |
TUSCHER![]() |
KPB ![]() |
375 ![]() |
456 ![]() |
BRAIDED![]() |
DRR![]() |
150 ![]() |
456 ![]() |
BRAIDED![]() |
KPB ![]() |
275 ![]() |
456 ![]() |
TUSCHER![]() |
BTM ![]() |
500 ![]() |
456 ![]() |
TUSCHER![]() |
DRR![]() |
550 ![]() |
456 ![]() |
TUSCHER![]() |
ERK ![]() |
525 ![]() |
All columns are string columns except MD, which is Real, however no math is required.所有列都是字符串列,但 MD 除外,MD 是实数,但不需要数学。
I need to filter the data so that only one row for a particular UWI and formation are returned based on a set hierarchy of the SOURCE.我需要过滤数据,以便根据 SOURCE 的一组层次结构仅返回特定 UWI 和编队的一行。
The hierarchy is:层次结构是:
What I'm looking for is a table that looks like this once the filter is applied:我正在寻找的是应用过滤器后看起来像这样的表格:
UWI![]() |
FORM![]() |
SOURCE![]() |
MD![]() |
---|---|---|---|
123 ![]() |
BRAIDED![]() |
ERK ![]() |
150 ![]() |
123 ![]() |
TUSCHER![]() |
MDB![]() |
350 ![]() |
456 ![]() |
BRAIDED![]() |
DRR![]() |
150 ![]() |
456 ![]() |
TUSCHER![]() |
ERK ![]() |
525 ![]() |
What is the best way to accomplish this?完成此任务的最佳方法是什么? I thought about adding a DenseRank calculated column, which will group the rows by UWI and FORM using SOURCE for the ranking, but there are two problems with that:
我想过添加一个 DenseRank 计算列,它将使用 SOURCE 进行排名,按 UWI 和 FORM 对行进行分组,但这样做有两个问题:
I've thought of using a Case statement, but I'm not sure how to group the UWI and FORM (I know about OVER, but every example I've found requires some kind of number column to do an aggregation).我想过使用 Case 语句,但我不确定如何对 UWI 和 FORM 进行分组(我知道 OVER,但我发现的每个示例都需要某种数字列来进行聚合)。
This filter will be applied just after import.此过滤器将在导入后立即应用。
Any direction would be greatly appreciated!任何方向将不胜感激!
I received an answer from the Tibco community on how to do this:我从 Tibco 社区收到了关于如何执行此操作的答复:
On top menu:在顶部菜单:
Data > Column Properties > select SOURCE数据 > 列属性 > select SOURCE
Choose Sort Order tab.选择排序选项卡。
Choose Custom Sort Order and configure the desired order选择自定义排序顺序并配置所需的顺序
press OK按确定
Now define the calculated column [SourceRank] as现在将计算列 [SourceRank] 定义为
DenseRank([SOURCE],Concatenate([FORM],[UWI]))
The filter can then be applied to [SourceRank]=1.然后可以将过滤器应用于 [SourceRank]=1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.