Forum Discussion
Calculated column to flag first occurences only
I've got a column with repetitive ID's and I'm trying to get a calculated column to flag first entries (or any as long as it's one flag only per group of ID's), with the remaining rows being flagged as somthing else, or blank. Example of what I'm trying to achieve (I need the Flag claculated column).
| ID | Flag |
| 123 | 1 |
| 123 | 0 |
| 123 | 0 |
| 158 | 1 |
| 158 | 0 |
| 784 | 1 |
| 784 | 0 |
| 784 | 0 |
| 784 | 0 |
| 966 | 1 |
| 966 | 0 |
I've tried a ranking, with a combination of ID = Earlier ID etc
andrewkla , Add and index column in power query and then add a new column in Dax
https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
new column =
var _min =minx(filter(Table, [ID] = earlier([ID])),[Index])
return
if ([Index] = _min , 1, , blank())
2 Replies
- amitchandak
Super User
andrewkla , Add and index column in power query and then add a new column in Dax
https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi
new column =
var _min =minx(filter(Table, [ID] = earlier([ID])),[Index])
return
if ([Index] = _min , 1, , blank()) - andrewklaFrequent Visitor
Thank you, this worked like a charm! (There's an unnecessary comma in the last line). Thanks for this!