Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gjohnson900
Helper I
Helper I

computed column that references the "next" row in the same table?

I've got a [Season] table that looks like this...

 

just_season.JPG

 

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...

 

added_nexty.JPG

 

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!

1 ACCEPTED SOLUTION
Anonymous
Not 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
    NextSeasonName

CurrentSeason grabs the name that's currently selected.  CurrentID gets the serial number.

 

Then you grab the season name that corresponds to CurrentID + 1.

View solution in original post

4 REPLIES 4
Anonymous
Not 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
    NextSeasonName

CurrentSeason grabs the name that's currently selected.  CurrentID gets the serial number.

 

Then you grab the season name that corresponds to CurrentID + 1.

Anonymous
Not applicable

When I apply this code, it gives this error: "A circular dependancy was detected..."

Why? and how to solve this issue?

Anonymous
Not applicable

Hi. How do we go about this if there is no index ID?

I've never used Variables like that before, so it took me a minute wrap my head around it.  Working great now, thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.