Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alteration to unstack a result-set #512

Closed
Seddryck opened this issue Aug 26, 2019 · 1 comment
Closed

Alteration to unstack a result-set #512

Seddryck opened this issue Aug 26, 2019 · 1 comment

Comments

@Seddryck
Copy link
Owner

Seddryck commented Aug 26, 2019

It should be possible unstack (or pivot) a result-set. A first set of columns (key-columns) is used to determine which row should be grouped together. Each unique group of values for the key-columns will create a new row in the resulting result-set. The distinct values of a column (the header-column) become columns of the resulting dataset.

<alteration>
  <unstack>
    <header>
      <column identifier="myHeaderColumn"/>
    </header>
    <group-by>
      <column identifier="myKeyColumn" type="text"/>
    </group-by>
  </unstack>
</alteration>

It means that the following table

Key1 Header1 Value1
one a 1.0
one b 2.0
two a 3.0
two b 4.0

will be reshapped to

Key1 a b
one 1.0 2.0
two 3.0 4.0

If more than one value column is present then the resulting header will be the concatenation of the header column and the value column name.

Key1 Header1 Value1 Value2
one a 1.0 -1.0
one b 2.0 -2.0
two a 3.0 -3.0
two b 4.0 -4.0

will be reshaped to

Key1 a_Value1 b_Value1 a_Value2 b_Value2
one 1.0 2.0 -1.0 -2.0
two 3.0 4.0 -3.0 -4.0

If at any moment, two rows of the initial table try to fill the same cell of the resulting table, then the reshapping is failing.

@Seddryck
Copy link
Owner Author

Beta available in 1.21.0-beta0313

Seddryck pushed a commit that referenced this issue Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant