Forum Discussion
abelrmg
Helper II
6 years agoHELP INDEX COLUMN WITH RANGES
I have a two columns "JOB" and "ROL", Job is a incremental number and "ROL" this could be "A","B" or "C". And I would like to add a column like index considering how many equals roles there are for each job, as the folowing example:
| JOB | ROL | INDEX RESULT |
| 1 | A | 1 |
| 1 | A | 2 |
| 1 | B | 1 |
| 1 | C | 1 |
| 2 | A | 1 |
| 2 | B | 1 |
| 2 | C | 1 |
| 3 | A | 1 |
| 3 | B | 1 |
| 3 | B | 2 |
| 3 | B | 3 |
| 3 | C | 1 |
5 Replies
- parry2k
Super User
Not sure what you mean by dynamic, it should work. May be I am missing something.
- Mariusz
Community Champion
Hi abelrmg
You can try something like below.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJUitVBZznBWc5glhFc1gguawSXNYbLGsNlcbGAOmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [JOB = _t, ROL = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"JOB", Int64.Type}, {"ROL", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"JOB", "ROL"}, {{"Index", each Table.AddIndexColumn( _, "Index", 1 )[Index], type list }}), #"Expanded Index" = Table.ExpandListColumn(#"Grouped Rows", "Index"), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Index",{{"Index", Int64.Type}}) in #"Changed Type1"Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.