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
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
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.