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
joshua1990
Post Prodigy
Post Prodigy

Lookup next state based on current state

Hi experts!

I have a table that shows me the current working step for each work order:

Order NrStep Article
100A1 A
101B2 A

 

This table is linked to a dimensional table that contains a unique list of all articles.

This unique list is linked to another table, that shows me for each article all possible steps:

ArticleSequenceStep
A1A1
A2B1
A4B2
A8C3

 

Now I would like to calculated in the first table (calculated column) the next step for each work order, based on this logic, based on the sequence.

As you can see the sequence number is not continous filled. There are missing numbers.

How can I determine the next step for each work order?

 

 

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @joshua1990 ,

 

Please refer this formula.

Column = 
var seq = CALCULATE(MAX(TableB[Sequence]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Step]=TableA[Step]))
var nextseq = CALCULATE(MIN(TableB[Sequence]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Sequence]>seq))
return
CALCULATE(MAX(TableB[Step]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Sequence]=nextseq))

vjaywmsft_0-1652865835163.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @joshua1990 ,

 

Please refer this formula.

Column = 
var seq = CALCULATE(MAX(TableB[Sequence]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Step]=TableA[Step]))
var nextseq = CALCULATE(MIN(TableB[Sequence]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Sequence]>seq))
return
CALCULATE(MAX(TableB[Step]),FILTER(TableB,TableB[Article]=TableA[Article]&&TableB[Sequence]=nextseq))

vjaywmsft_0-1652865835163.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Untitled.png

 

Next Step CC =
VAR currentarticle = Data[Article]
VAR currentstep = Data[Step]
VAR currentsequence =
    LOOKUPVALUE (
        DimTable[Sequence],
        DimTable[Article], currentarticle,
        DimTable[Step], currentstep
    )
VAR nextsequesnce =
    MINX (
        FILTER (
            ALL ( DimTable ),
            DimTable[Article] = currentarticle
                && DimTable[Sequence] > currentsequence
        ),
        DimTable[Sequence]
    )
RETURN
    SUMMARIZE (
        FILTER (
            ALL ( DimTable ),
            DimTable[Article] = currentarticle
                && DimTable[Sequence] = nextsequesnce
        ),
        DimTable[Step]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


tamerj1
Super User
Super User

Hi @joshua1990 

you can try

Next Step =
VAR CurrentSequence =
    RELATED ( DimTable[Sequence] )
VAR NextStepSequence =
    MINX (
        FILTER ( DimTable, DimTable[Sequence] > CurrentSequence ),
        DimTable[Sequence]
    )
RETURN
    MAXX (
        FILTER ( DimTable, DimTable[Sequence] = NextStepSequence ),
        DimTable[Step]
    )

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.

Top Solution Authors