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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Measure result based on OR conditions

 
Hi Community,

 

In the following dataset, I created a measure that counts distinct clients where contact type <> "EM" || val1 <> 'Y'|| val2<>"Y".

Measure =
CALCULATE (
DISTINCTCOUNT ('Table'[Client] ),
'Table'[Contact Type] <> "EM"
|| 'Table'[Val1] = "N"
|| 'Table'[Val2] = "N"
)
ExcelPBI_1-1647326950030.png

 

But the measure reutns 9 clients, I expect 6 (higlighted in yellow). 

 

The logic is to return the clients who have not provided EM contact type OR not provided Val1 Or Not provided Val2.

 

My PBI file:  https://1drv.ms/u/s!Ag919_pO_UKrgThqrNGx2Dwbp9Q6?e=YjOLvi

Any help is appreciated. Thanks

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Anonymous ,

the measure is a little more complex:

Measure 2 = 
var t_not_EM = 
    CALCULATETABLE(
        VALUES( 'Table'[Client] )
        ,'Table'[Contact Type] <> "EM"
    )
var t_EM = 
    CALCULATETABLE(
        VALUES( 'Table'[Client] )
        ,'Table'[Contact Type] = "EM"
    )
var notEM =
    EXCEPT(
        t_not_EM
        , t_EM
    )
var t_VAL1_VAL2 = 
    EXCEPT(
        CALCULATETABLE(
            VALUES( 'Table'[Client] )
            ,'Table'[Val1] = "N" || 'Table'[Val2] = "N"
        )
        , notEM
    )
return
    COUNTROWS(
        UNION(
            notEM
            , t_VAL1_VAL2
        )
    )


Based on the measure you get this result on a card visual:

image.png

If you use CONCATENATEX instead of COUNTROWS you will get this on the card visual:

...
CONCATENATEX(
        UNION(
            notEM
            , t_VAL1_VAL2
        )
        , 'Table'[Client]
        , " | "
    )

The card visual:
image.png
Hopefully, this provides what you are looking for.

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey @Anonymous ,

the measure is a little more complex:

Measure 2 = 
var t_not_EM = 
    CALCULATETABLE(
        VALUES( 'Table'[Client] )
        ,'Table'[Contact Type] <> "EM"
    )
var t_EM = 
    CALCULATETABLE(
        VALUES( 'Table'[Client] )
        ,'Table'[Contact Type] = "EM"
    )
var notEM =
    EXCEPT(
        t_not_EM
        , t_EM
    )
var t_VAL1_VAL2 = 
    EXCEPT(
        CALCULATETABLE(
            VALUES( 'Table'[Client] )
            ,'Table'[Val1] = "N" || 'Table'[Val2] = "N"
        )
        , notEM
    )
return
    COUNTROWS(
        UNION(
            notEM
            , t_VAL1_VAL2
        )
    )


Based on the measure you get this result on a card visual:

image.png

If you use CONCATENATEX instead of COUNTROWS you will get this on the card visual:

...
CONCATENATEX(
        UNION(
            notEM
            , t_VAL1_VAL2
        )
        , 'Table'[Client]
        , " | "
    )

The card visual:
image.png
Hopefully, this provides what you are looking for.

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
darshaningale
Resolver II
Resolver II

Please explain why you dont want the below rows ? 

darshaningale_0-1647330391496.png

 

If you create a new column ("valid" below) with your filter criteria , it shows 9 clients.

darshaningale_1-1647330451896.png

Regards

DI

 

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

The reason why you are getting 9 is you have added OR condition in type and val1,2 so its considering all type which is not EM in the count. Based on condition you are getting correct output so kindly revisit the condition. 🙂

 

Samarth_18_0-1647329566646.png

 

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

VIJAYKUMART
Resolver I
Resolver I

Hi.. can u please specify data u have and data output that satiffies condition in excel by using filters in excel..  the output logic is not clear

Anonymous
Not applicable

@VIJAYKUMART  The output logic is to return the clients who have not provided EM contact type OR not provided Val1 Or Not provided Val2. As you see in the dataset a client can have more than one Contact type  like H,O,EM. This is the difficult part of the logic.

for example :

ExcelPBI_0-1647329797000.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors