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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
CRN
Helper I
Helper I

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

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 ?

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.