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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
joshua1990
Post Prodigy
Post Prodigy

Calculated Column Get next Value per Group in same Table

Hi community!

I have a table that contains dimensional data and values:

ArticleStepInfoNext Info
AA1X1X2
AA2X2X3
AA3X3X3
AB1B1B2
AB2B2B2

 

This table contains 3 columns:

  • Article: Name of Article
  • Step: Step Number
  • Info: Text Information

Now I would like to add a 4th column that shows me per Article the next Information based on the Step.

If it is the last step then the information for the current step should be displayed.

 

How is this possible using DAX?

 

3 ACCEPTED SOLUTIONS
AlB
Community Champion
Community Champion

Hi @joshua1990

 

NextInfo =
VAR nextStep_ =
    CALCULATE (
        MIN ( Table1[Step] ),
        Table1[Step] > EARLIER ( Table1[Step] ),
        ALLEXCEPT ( Table1, Table1[Article] )
    )
RETURN
    IF (
        ISBLANK ( nextStep_ ),
        Table1[Info],
        CALCULATE (
            DISTINCT ( Table1[Info] ),
            Table1[Step] = nextStep_,
            ALLEXCEPT ( Table1, Table1[Article] )
        )
    )

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

 

View solution in original post

@AlB : Thanks a lot! It is not working:

"A table of multiple values was supplied where a single value was expected.".

I guess we need also the article r as a filter since since the steps are different between the articles. 

View solution in original post

AlB
Community Champion
Community Champion

@joshua1990 

It already has the filter on the article: through context transition and the ALLEXCEPT().

It does work in the data you have provided. See the attached file.

 

If you get that error it means that your data has more than one value in the column Info for the same article-Step combination. You'd need to review your data or decide what to do in those cases: which Info value do you keep? If for instance you want to keep the first one alphabetically, it suffices with using MIN instead of the DISTINCT on the code    

NextInfo =
VAR nextStep_ =
    CALCULATE (
        MIN ( Table1[Step] ),
        Table1[Step] > EARLIER ( Table1[Step] ),
        ALLEXCEPT ( Table1, Table1[Article] )
    )
RETURN
    IF (
        ISBLANK ( nextStep_ ),
        Table1[Info],
        CALCULATE (
            MIN ( Table1[Info] ),
            Table1[Step] = nextStep_,
            ALLEXCEPT ( Table1, Table1[Article] )
        )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

Hi @joshua1990

 

NextInfo =
VAR nextStep_ =
    CALCULATE (
        MIN ( Table1[Step] ),
        Table1[Step] > EARLIER ( Table1[Step] ),
        ALLEXCEPT ( Table1, Table1[Article] )
    )
RETURN
    IF (
        ISBLANK ( nextStep_ ),
        Table1[Info],
        CALCULATE (
            DISTINCT ( Table1[Info] ),
            Table1[Step] = nextStep_,
            ALLEXCEPT ( Table1, Table1[Article] )
        )
    )

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

 

@AlB : Thanks a lot! It is not working:

"A table of multiple values was supplied where a single value was expected.".

I guess we need also the article r as a filter since since the steps are different between the articles. 

AlB
Community Champion
Community Champion

@joshua1990 

It already has the filter on the article: through context transition and the ALLEXCEPT().

It does work in the data you have provided. See the attached file.

 

If you get that error it means that your data has more than one value in the column Info for the same article-Step combination. You'd need to review your data or decide what to do in those cases: which Info value do you keep? If for instance you want to keep the first one alphabetically, it suffices with using MIN instead of the DISTINCT on the code    

NextInfo =
VAR nextStep_ =
    CALCULATE (
        MIN ( Table1[Step] ),
        Table1[Step] > EARLIER ( Table1[Step] ),
        ALLEXCEPT ( Table1, Table1[Article] )
    )
RETURN
    IF (
        ISBLANK ( nextStep_ ),
        Table1[Info],
        CALCULATE (
            MIN ( Table1[Info] ),
            Table1[Step] = nextStep_,
            ALLEXCEPT ( Table1, Table1[Article] )
        )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.