cancel
Showing results for
Did you mean:
Highlighted
Regular Visitor

## Count numbers based on two conditions for OR statement

Hello,

I have three tables, join with order ID on 1:1 relationship.

Table A has all orders information

Table B has orders that are scaned as late

Table C has oerder that are repored as late

(so B and C may has same order ID, same you can report it as late but at the same time report it as late)

so I want to count in Table A, how many unqiue orders are scaned as late or report as late

I don't know how to do that, but I tried tha following formula, it gives me the number, just want to make sure if there any another good solution or I am lucky to get the best one?

Lates=CALCULATE(DISTINCTCOUNT('A'[SALE_ID]),filter('A',RELATED(C[Report_Late])<>blank()||RELATED(B[LATE_FLAG])="Y"))

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Count numbers based on two conditions for OR statement

HI @NoobAnalyst01,

I'd like to suggest you use below measure to get matched row count:

```distinc =
COUNTROWS (
FILTER (
ALL ( TableA ),
TableA[SALE_ID]
IN UNION (
INTERSECT ( VALUES ( TableA[SALE_ID] ), VALUES ( TableB[SALE_ID] ) ),
INTERSECT ( VALUES ( TableA[SALE_ID] ), VALUES ( TableC[SALE_ID] ) )
)
)
)
```

Regards,

Xiaoxin Sheng

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

For learning resources/Release notes, please visit: | |
Community Support Team

## Re: Count numbers based on two conditions for OR statement

HI @NoobAnalyst01,

I'd like to suggest you use below measure to get matched row count:

```distinc =
COUNTROWS (
FILTER (
ALL ( TableA ),
TableA[SALE_ID]
IN UNION (
INTERSECT ( VALUES ( TableA[SALE_ID] ), VALUES ( TableB[SALE_ID] ) ),
INTERSECT ( VALUES ( TableA[SALE_ID] ), VALUES ( TableC[SALE_ID] ) )
)
)
)
```

Regards,

Xiaoxin Sheng

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

For learning resources/Release notes, please visit: | |

Announcements

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 124 members 1,572 guests
Recent signins: