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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NoobAnalyst01
Helper I
Helper I

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
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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