简体   繁体   English

通过子列值计算列值

[英]Calculate column value by sub-column value

I know this will require an advanced custom expression - I have 2 relevant columns, commodity and sub-commodity. 我知道这将需要一个高级自定义表达式-我有2个相关的列,商品和子商品。 A single event can have multiple commodities and sub-commodities. 一个事件可以包含多个商品和子商品。 However, some commodities will naturally have more data about them. 但是,某些商品自然会拥有更多有关它们的数据。 I don't want this to skew representation of the data. 我不想这样歪曲数据的表示形式。

I want to avoid that by counting values by their unique sub-commodity. 我想通过按其唯一的子商品计算值来避免这种情况。 In the below example, I want the bar chart to represent two instances of food for Event 1 (1 for meat, 1 for beverages) and one instance of garden for Event 2. How do I accomplish this? 在下面的示例中,我希望条形图表示事件1的两个食物实例(肉类1个,饮料1个实例)和事件2的一个花园实例。如何做到这一点?

EventID | Commodity | Sub-Commodity
  1         Food         Meat
  1         Food         Meat
  1         Food         Beverages
  2         Garden       Lawn Mower
  2         Garden       Lawn Mower   

Thanks for the sample data. 感谢您提供示例数据。 It helps in providing an answer. 它有助于提供答案。

You should be able to do this by using the UniqueCount() function. 您应该能够通过使用UniqueCount()函数来执行此操作。 In this case the Y axis would be the expression UniqueCount([Sub-Commodity]). 在这种情况下,Y轴将为表达式UniqueCount([Sub-Commodity])。 You can use custom expressions to input this or use the built-in drop down and select UniqueCount from the aggregation drop-down. 您可以使用自定义表达式来输入此内容,也可以使用内置下拉菜单并从聚合下拉列表中选择UniqueCount。

Take a look at the below image showing my implementation with a custom expression. 请看下面的图片,其中显示了使用自定义表达式的实现。 Coloring is optional but I did so to show how it included your multiple sub-commodities and how they were counted (1 for Food=>Meat). 着色是可选的,但我这样做是为了显示它如何包含您的多个子商品以及如何对其进行计数(对于Food => Meat,则为1)。

spotfire_example_1

See below for an example with the drop-down: 请参见下面的下拉菜单示例:

spotfire_example_2

Let me know if you have any questions or need further clarification. 如果您有任何疑问或需要进一步澄清,请告诉我。 Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM