Forum Discussion
Anonymous
3 years agoNot applicable
When Id has changed assign value 1
I've been trying to find either a Power Query code or DAX code that allows me to assign the value 1 when the ID within my column table has changed. So I have a table that has an ID column that has du...
- Anonymous3 years ago
The following thread was a quicker method for me to apply which did the job.
Anonymous
3 years agoNot applicable
Hi Anonymous
Create a sample like this :
Then create a calculated column to group .
Group_Index =
RANKX(FILTER(ALL('Table'),'Table'[GROUP]=EARLIER('Table'[GROUP])),[Index],,ASC)
You will get a result like this :
Finally , create a calculated column to compare the ID .
True =
var _1=SUMX(FILTER(ALL('Table'),'Table'[GROUP]=EARLIER('Table'[GROUP])&&'Table'[Index]=EARLIER('Table'[Index])),[ID])
var _2=SUMX(FILTER(ALL('Table'),'Table'[GROUP]=EARLIER('Table'[GROUP])&&'Table'[Index]=EARLIER('Table'[Index])-1),[ID])
var _minindex=MINX(FILTER(ALL('Table'),'Table'[GROUP]=EARLIER('Table'[GROUP])),[Index])
return
IF([Index]=_minindex|| _1= _2,0, SUMX(FILTER(ALL('Table'),'Table'[GROUP]=EARLIER('Table'[GROUP])&&'Table'[Index]=EARLIER('Table'[Index])-1),[Group_Index]))
The fianl result is like this :
Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.