简体   繁体   中英

Computed field on pivot table

here there is my table

N   tag
1   7-3
2   3-4
3   2-4
4   5-3
5   4-6
6   3-1
7   3-1
8   3-4
9   5-6

I need to create a Pivot Table (I do not know how many rows there will be) with the first value of Tag. Example :

B2="7-3"  ---> =VALUE(LEFT(B2;FIND( "-";B2 ) - 1 )) = 7

So the expected table should be:

N   FirstTag
1   7
2   3
3   2
4   5
5   4
6   3
7   3
8   3
9   5

When I create the computed field for the pivot table I get error: 在此处输入图片说明

Can you help me? Riccardo

You don't have access to all of the normal functions in a Calculated Field . Check out this previous Q&A about the topic. It looks like you may only have access to SUM . I have not confirmed that though.

I would recommend creating a Table with the formula added as a column formula. This allows it to apply to all of the rows that you don't know exist yet. You can then summarize the Table with a Pivot Table and the Data Source will expand/contract as needed.

Picture of resulting table and Pivot , not sure what the Pivot is for so I just put the fields in a hierarchy.

图片

Formula in FIRST TAG

=VALUE(LEFT([@TAG],FIND( "-",[@TAG] ) - 1 ))

The PT example you show has a row for (blank) so if you don't mind that, or are happy enough with filtering out that row, I'd not worry about not knowing how many rows of data you may receive – merely pivot entire columns.

Then it is really just a question of how to get from nm to n format. Options for which include:

  1. a formula that extracts up to but not including the hyphen (yours and @Byron's approach)
  2. Text to Columns with - as the delimiter (the right-hand column then ignorable)

    and, my preference

  3. Find what: -* , Replace with nothing.

Refresh the PT when new data is imported.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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