Forum Discussion
Add consecutive incremental counter in filtered table
Hi All,
I've been searching the community for examples of a similar request but can't find one relevant to the scenario I have.
I need to add a column which counts upwards 1,2,3,4 etc, but the values need to be dynamic so no matter if a filter is applied to a table, the increments are still 1 each time. The aim is to get a unique, consequtive record ID for every record in the filtered table
Unfiltered:
| Customer | ID Column |
| A | 1 |
| B | 2 |
| C | 3 |
| D | 4 |
| E | 5 |
Filtered:
| Customer | ID Column |
| A | 1 |
| D | 2 |
| E | 3 |
Many thanks in advance,
Nick
3 Replies
- amitchandak
Super User
wynrod , Try a new measure
countx(filter(allselected(Table), Table[CustomerID] <=max(Table[CustomerID])),Table[CustomerID])
- wynrodFrequent Visitor
Hi amitchandak ,
Thanks for your quick reply.
Your suggestion worked great with small datasets but as soon as it's scaled-up to work with larger volumes (100k+), the measure prevents the data being displayed due to the time it cases to compute the values (both in desktop and published service).
Do you know if using a variable would be more efficient? I've spent time trying to put something in place using variables but haven't found a way yet.
Cheers,
Nick
- AnonymousNot applicable
Hi wynrod ,
Try
Measure = CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),'Table'[Column1]<=MAX('Table'[Column1])))Or
Measure 2 = MAX('Table'[Column1]) Measure 3 = RANKX(ALLSELECTED('Table'),[Measure 2],,ASC,Dense)Best Regards,
Jay