Forum Discussion
computed column that references the "next" row in the same table?
I've got a [Season] table that looks like this...
I'm using this table as a slicer, and when a particular SeasonName is selected, I'd like to be able to be able to show the "next" season as a label for a visual. If I could create a computed column called "Next Season" like this, it would be ideal...
Is there any easy way to make this happen? I've been trying CALCULATE and FILTER, but haven't been able to get them to do reference the next row based on SeasonId.
I'm hoping this is a quicky and I'm just being myopic. PLEASE HELP!
- Anonymous8 years ago
You can use variables to help! This will be easy because you SeasonID is a serial ID column.
[Next Season] = VAR CurrentSeason = SELECTEDVALUE ( Table[SeasonName] ) VAR CurrentID = CALCULATE ( MIN ( Table[SeasonID] ), Table[SeasonName] = CurrentSeason ) VAR NextSeasonName = CALCULATE ( VALUES ( Table[SeasonName] ), Table[SeasonID] = CurrentSeason + 1 ) RETURN NextSeasonNameCurrentSeason grabs the name that's currently selected. CurrentID gets the serial number.
Then you grab the season name that corresponds to CurrentID + 1.
4 Replies
- AnonymousNot applicable
You can use variables to help! This will be easy because you SeasonID is a serial ID column.
[Next Season] = VAR CurrentSeason = SELECTEDVALUE ( Table[SeasonName] ) VAR CurrentID = CALCULATE ( MIN ( Table[SeasonID] ), Table[SeasonName] = CurrentSeason ) VAR NextSeasonName = CALCULATE ( VALUES ( Table[SeasonName] ), Table[SeasonID] = CurrentSeason + 1 ) RETURN NextSeasonNameCurrentSeason grabs the name that's currently selected. CurrentID gets the serial number.
Then you grab the season name that corresponds to CurrentID + 1.
- AnonymousNot applicable
Hi. How do we go about this if there is no index ID?
- gjohnson900
Helper I
I've never used Variables like that before, so it took me a minute wrap my head around it. Working great now, thanks
- AnonymousNot applicable
When I apply this code, it gives this error: "A circular dependancy was detected..."
Why? and how to solve this issue?