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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Need help: Calculating with restrictions

Dear DAX expert,

 

Previously I calculated the change over time between production orders with the following DAX:

 

Omsteltijden in seconden = 
VAR lastProductID =
    CALCULATE (
        MIN ( RegistratieMaasland[ProductieID] );
        FILTER (
            ALL ( RegistratieMaasland );
            RegistratieMaasland[Aansturing] = MIN ( RegistratieMaasland[Aansturing] )
                && RegistratieMaasland[Lijn] = MIN ( RegistratieMaasland[Lijn] )
                && RegistratieMaasland[ProductieID]
                    = MIN ( RegistratieMaasland[ProductieID] ) - 1
        )
    )
VAR endTime =
    MIN ( RegistratieMaasland[Begintijd def] )
VAR startTime =
    CALCULATE (
        MIN ( RegistratieMaasland[Eindtijd def] );
        FILTER (
            ALL ( RegistratieMaasland );
            RegistratieMaasland[ProductieID] = lastProductID
        )
    )
RETURN
    DATEDIFF ( StartTime; endTime; SECOND )
Valid outcome = 
SUMX (
    RegistratieMaasland;
     IF( [Omsteltijden in seconden] >=0
            && [Omsteltijden in seconden] <= 1800;
            [Omsteltijden in seconden];
        BLANK())
     )

 

Now I would like to change the valid outcome formula in a way that the outcomes are only valid when subnummer between productID has changed. This basically means that the changeover between an order is real (because of the change of subnummer). 

 

Check herebelow for an example.

 

All help is greatly appreciated, if its not clear please ask,

 

 

tempsnip.png

1 ACCEPTED SOLUTION
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may try to use below measure:

 

Valid outcome =
VAR lastSubnumber =
LOOKUPVALUE (
RegistratieMaasland[Subnumber],
RegistratieMaasland[ProductieID], MAX ( RegistratieMaasland[ProductieID] ) - 1
)
RETURN
IF (
MAX ( RegistratieMaasland[Subnumber] ) = lastSubnumber,
BLANK (),
[Omsteltijden in seconden]
)

Regards,

 

Cherie

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

View solution in original post

1 REPLY 1
v-cherch-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

You may try to use below measure:

 

Valid outcome =
VAR lastSubnumber =
LOOKUPVALUE (
RegistratieMaasland[Subnumber],
RegistratieMaasland[ProductieID], MAX ( RegistratieMaasland[ProductieID] ) - 1
)
RETURN
IF (
MAX ( RegistratieMaasland[Subnumber] ) = lastSubnumber,
BLANK (),
[Omsteltijden in seconden]
)

Regards,

 

Cherie

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

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors