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

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

Reply
joshua1990
Post Prodigy
Post Prodigy

Calculated Column Lookup next greater value

Hi experts!

I have a dimensional table that shows me the number of working steps per Article and a different table that contains the current state per article.

Dimensional table

ArticleStepValue
AB15
AB24
AB38
AT18
AT27

 

 Value Table

ArticleCurrent StepNext Step Value
AB28
AB14

 

Both tables are linked Many-to-Many.

What I would like to get is the column "Next Step Value" that shows me the Value for the next step.

How is this possible using DAX? 

If the current step is the last step, I would like to get "Current Step" value

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @joshua1990 

please use

Next Step Value =
VAR CurrentStep = 'Value Table'[Current Step]
VAR RelatedStepsTable =
    RELATEDTABLE ( 'Dimensional table' )
VAR CurrentStepTable =
    FILTER ( RelatedStepsTable, 'Dimensional table'[Step] = CurrentStep )
VAR CurrentValue =
    MAXX ( CurrentStepTable, 'Dimensional table'[Value] )
VAR NextStepsTable =
    FILTER ( RelatedStepsTable, 'Dimensional table'[Step] > CurrentStep )
VAR NextStep =
    MINX ( NextStepsTable, 'Dimensional table'[Step] )
VAR NextValue =
    MAXX (
        FILTER ( NextStepsTable, 'Dimensional table'[Step] = NextStep ),
        'Dimensional table'[Step]
    )
RETURN
    IF ( ISBLANK ( CurrentValue ), NextValue, CurrentValue )

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

As composite keys are not supposed in either PBI or SSAS tabular model, such a rookie's question is, in fact, fairly tricky and demanding.

CNENFRNL_0-1655655657216.png

 

A showcase of powerful Excel worksheet formula,

CNENFRNL_1-1655657664466.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

Hi @joshua1990 

please use

Next Step Value =
VAR CurrentStep = 'Value Table'[Current Step]
VAR RelatedStepsTable =
    RELATEDTABLE ( 'Dimensional table' )
VAR CurrentStepTable =
    FILTER ( RelatedStepsTable, 'Dimensional table'[Step] = CurrentStep )
VAR CurrentValue =
    MAXX ( CurrentStepTable, 'Dimensional table'[Value] )
VAR NextStepsTable =
    FILTER ( RelatedStepsTable, 'Dimensional table'[Step] > CurrentStep )
VAR NextStep =
    MINX ( NextStepsTable, 'Dimensional table'[Step] )
VAR NextValue =
    MAXX (
        FILTER ( NextStepsTable, 'Dimensional table'[Step] = NextStep ),
        'Dimensional table'[Step]
    )
RETURN
    IF ( ISBLANK ( CurrentValue ), NextValue, CurrentValue )

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.