cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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.

1 ACCEPTED SOLUTION
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.
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.

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors