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
Kudy
Helper I
Helper I

Measure that counts names column "A" which have only one/single occurance in column "B"

Hi,

what function shall i use for a measure that dcounts names column "Name" which have only one/single occurance in column "Product".

what I have:

Skärmbild 2021-11-16 082626.png

I want my measure to show:
Dcount of names that have only apples (BBB and DDD) = 2.

I can solve this with 2 steps but this way seems a bit coplicated.

1. adding an extra column "C" that shows how many distinct products each Name has;
2. and then creating a measure e.g. calculate(distinctcount(NAME), C = 1, Product = "apple". C = 1 means that eg DDD has only 1 product. 
 
thank you in advance

1 ACCEPTED SOLUTION

Hi, @Kudy 

In fact, your original solution is sufficiently general and straightforward. The code I provide below is just to give you a different idea.

Measure1 = 
VAR tab1 =
    SUMMARIZE (
        'Table',
        'Table'[Name],
        "first_product", MIN ( 'Table'[Product] ),
        "last_product", MAX ( 'Table'[Product] )
    )
RETURN
    COUNTROWS (
        FILTER ( tab1, [first_product] = "apple" && [last_product] = "apple" )
    )

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

HI @Kudy 

 

Try this:

Measure = calculate(distinctcount(table[name]),filter(all(table),table[product]="apple"))

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi Vahid, 
and thank you for your answer! 

I tried your solution but unfortunately did not get the result I needed. It gave me = 3 instead of 2

Hi, @Kudy 

In fact, your original solution is sufficiently general and straightforward. The code I provide below is just to give you a different idea.

Measure1 = 
VAR tab1 =
    SUMMARIZE (
        'Table',
        'Table'[Name],
        "first_product", MIN ( 'Table'[Product] ),
        "last_product", MAX ( 'Table'[Product] )
    )
RETURN
    COUNTROWS (
        FILTER ( tab1, [first_product] = "apple" && [last_product] = "apple" )
    )

Best Regards,
Community Support Team _ Eason

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.