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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Next production order on a machine

Hi all,

 

I'm trying to somewhat summarize a table with production data. I wan't to find the next production order set to be produced for each machine by due date and status.

 

I have the following data:

CRN_0-1656404957853.png

 

This is what i'm trying to get:

CRN_1-1656405003285.png

 

The criteria is as follows for each machine:

Production order with earliest due date and status pending.

If production orders have the same due date I wan't to display the lowest order number.

 

Thanks in advance!

 

Note: If necessary, I'll be able to exclude all production orders with status completed in advance of retrieving it.

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could create a measure like 

Is Next Order =
VAR currentOrderNo =
    SELECTEDVALUE ( 'Table'[Order no] )
VAR nextOrderNo =
    SELECTCOLUMNS (
        CALCULATETABLE (
            TOPN ( 1, 'Table', 'Table'[Due date], ASC, 'Table'[Order no], ASC ),
            ALLEXCEPT ( 'Table', 'Table'[Machine] ),
            'Table'[Status] = "Pending"
        ),
        "@val", 'Table'[Order no]
    )
RETURN
    IF ( currentOrderNo = nextOrderNo, 1 )

and then use that as a visual filter on your table to only show when the value is 1

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You could create a measure like 

Is Next Order =
VAR currentOrderNo =
    SELECTEDVALUE ( 'Table'[Order no] )
VAR nextOrderNo =
    SELECTCOLUMNS (
        CALCULATETABLE (
            TOPN ( 1, 'Table', 'Table'[Due date], ASC, 'Table'[Order no], ASC ),
            ALLEXCEPT ( 'Table', 'Table'[Machine] ),
            'Table'[Status] = "Pending"
        ),
        "@val", 'Table'[Order no]
    )
RETURN
    IF ( currentOrderNo = nextOrderNo, 1 )

and then use that as a visual filter on your table to only show when the value is 1

Anonymous
Not applicable

Hi @johnt75 ,

 

Thank you for your suggestion.

I've tried it out and also tweaked it a little to see if it fixes the results.

 

It works if i apply a few more filters on the visual. So my initial issue has been resolved.

 

I tried to add another filter like you did on the status, but they don't seem to work.

Can you help me figure out why? Do I place them wrong?

Is Next Order =
VAR currentOrderNo =
    SELECTEDVALUE ( 'Table'[Order no] )
VAR nextOrderNo =
    SELECTCOLUMNS (
        CALCULATETABLE (
            TOPN ( 1, 'Table', 'Table'[Due date], ASC, 'Table'[Order no], ASC ),
            ALLEXCEPT ( 'Table', 'Table'[Machine] ),
            'Table'[Status] = "Pending",
            'Table'[OperationNo] = 100,
            'Table'[OrderType] = 1
        ),
        "@val", 'Table'[Order no]
    )
RETURN
    IF ( currentOrderNo = nextOrderNo, 1 )

 

 

They seem to be placed correctly. 

What filters are being applied to the visual? 

What exactly is not working ? What are you expecting to see and what are you actually seeing ?

Anonymous
Not applicable

I solved the issue.

 

Recently another Doc-Type was added to the dataset and I re-categorized them. Had a multiple filters interfering with one another. It works now.

 

Thank you so much for your help. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.