Forum Discussion
bullius
8 years agoHelper V
EARLIER function in M/Query Editor
Hi I have data that looks like this: ID Name 1 Apple 1 Banana 2 Orange 3 Pear 4 Pineapple 4 Grape 4 Mango 5 Peach I want it to look like this: ...
- 8 years ago
HI bullius,
Yes it is possible to do that in M.
To sum up group by your id and add an index.
You can add this code into your steps:
#"Grouped Rows" = Table.Group(#"Promoted Headers", {"ID"}, {{"Count", each Table.AddIndexColumn(_, "Index", 1, 1), type table}})Hope it helps...
Ninter
bullius
8 years agoHelper V
Thanks prateekraina. My actual dataset is much larger than the example and does not include a Rank field. My question is how do I create one? I would use the EARLIER function in DAX to make sure the ranking restarts with each new ID, but can't find an alternative in M.
Interkoubess
8 years agoSolution Sage
HI bullius,
Yes it is possible to do that in M.
To sum up group by your id and add an index.
You can add this code into your steps:
#"Grouped Rows" = Table.Group(#"Promoted Headers", {"ID"}, {{"Count", each Table.AddIndexColumn(_, "Index", 1, 1), type table}})
Hope it helps...
Ninter
- prateekraina8 years agoMemorable Member
Hi bullius,
Interkoubess is absolutely right. I haved added his step in the same pbix.
Prateek Raina
- bullius8 years agoHelper V
Thanks! That works.