Forum Discussion
create a Counter which adds +1
- Anonymous10 years ago
I'm guessing this is related to the MonthIndex you were asking about in that other thread. Even if it is not you should still be able to use the same pattern. That's the only way I could come up with of sequentially incrementing a previous number that only changes on arbitrary rows. ImkeF might have another method though. I'll have to try that one out.
Edit: now that I've said that, I just came up with a way to do it in DAX. See the link for the solution. I don't want to clutter up this thread with extra code if that solution doesn't quite apply to this question.
Ok, thanks for yout answer.
And if the counter only should add +1 if the value in another field change?
For example:
Date Counter
30.05.2016 1
30.05.2016 1
30.05.2016 1
02.06.2016 2
03.06.2016 3
03.06.2016 3
.
.
.
.
I'm guessing this is related to the MonthIndex you were asking about in that other thread. Even if it is not you should still be able to use the same pattern. That's the only way I could come up with of sequentially incrementing a previous number that only changes on arbitrary rows. ImkeF might have another method though. I'll have to try that one out.
Edit: now that I've said that, I just came up with a way to do it in DAX. See the link for the solution. I don't want to clutter up this thread with extra code if that solution doesn't quite apply to this question.
- Anonymous9 years agoNot applicable
Thought I would just post this as I have done something like this at the moment.
You could use List.Generate() as follows
List.Generate (() => [counter = 1, seq_val = 1], // this is our initial values each [counter] <= List.Count(my_list), // our terminating condition each [ seq_val = if my_value{[counter]} <> my_value{[counter] - 1} then [seq_val] + 1 else [seq_val], counter = [counter] + 1 ], // change seq_val if your value (which should be a list) changes each [seq_val] // now output the list )This gives you a list which you then need to integrate into your table.
- MarcelBeug9 years agoCommunity Champion
Why do you react on a topic that is more than a year old and provide code that doesn't even work?
- Anonymous9 years agoNot applicable
Thought someone might find it useful as I was passing through.
Code should work fine. I am using something like it right now. Just change the names of the variables as you require.
Provides another way to solve the problem.
- plukacsi8 years agoHelper I
Could you please ellaborate on "integrate the list"? I have got a list in every cell but I don't know how to use them.
Thank you!