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

Using ID number to find various associated products

Long time reader, first time posting...

 

I am looking to create a column that identifies if a customer has the required product, in addition to other products. Customers have ID numbers, and each product has a row. I am looking to add a column that uses the ID number as the lookup, and finds if that ID number has a row with the REQUIRED product name. The hope is to return a True vs False.

 

OR the inverse... use the ID number that has a row with the REQUIRED product, and return True vs False if there are other products associated with the ID number.

 

First scenario:

Customer ID #

Product Name

Has Required

1234

Required Product

True

5678

Optional Product

False

9100

Optional Product

False

1234

Optional Product

True

 

Second scenario:

Customer ID #

Product Name

Has Required

1234

Required Product

True

5678

Required Product

False

9100

Required Product

False

1234

Optional Product

True

 

I hope this makes sense. Any help would be greatly appreciated.

 

Thanks!

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have created a sample for your reference. Here I created two measures as below to work on different tables.

Measure = 
VAR c =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Customer ID #] ),
            'Table'[Product Name] = "Required Product"
        )
    )
VAR a =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer ID #] )
    )
RETURN
    IF ( c = BLANK (), FALSE (), IF ( a > c, TRUE (), IF ( a = c, FALSE () ) ) )
Measure 2 = 
VAR c =
    CALCULATE (
        COUNTROWS ( 'Table (2)' ),
        FILTER (
            ALLEXCEPT ( 'Table (2)', 'Table (2)'[Customer ID #] ),
            'Table (2)'[Product Name] = "Required Product"
        )
    )
VAR a =
    CALCULATE (
        COUNTROWS ( 'Table (2)' ),
        ALLEXCEPT ( 'Table (2)', 'Table (2)'[Customer ID #] )
    )
RETURN
    IF ( c = BLANK (), FALSE (), IF ( a > c, TRUE (), IF ( a = c, FALSE () ) ) )

 

Capture.PNG

 

Attached the pbix as well.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have created a sample for your reference. Here I created two measures as below to work on different tables.

Measure = 
VAR c =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Customer ID #] ),
            'Table'[Product Name] = "Required Product"
        )
    )
VAR a =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        ALLEXCEPT ( 'Table', 'Table'[Customer ID #] )
    )
RETURN
    IF ( c = BLANK (), FALSE (), IF ( a > c, TRUE (), IF ( a = c, FALSE () ) ) )
Measure 2 = 
VAR c =
    CALCULATE (
        COUNTROWS ( 'Table (2)' ),
        FILTER (
            ALLEXCEPT ( 'Table (2)', 'Table (2)'[Customer ID #] ),
            'Table (2)'[Product Name] = "Required Product"
        )
    )
VAR a =
    CALCULATE (
        COUNTROWS ( 'Table (2)' ),
        ALLEXCEPT ( 'Table (2)', 'Table (2)'[Customer ID #] )
    )
RETURN
    IF ( c = BLANK (), FALSE (), IF ( a > c, TRUE (), IF ( a = c, FALSE () ) ) )

 

Capture.PNG

 

Attached the pbix as well.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Nathaniel_C
Super User
Super User

HI @Anonymous ,

Try this.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel


Required product =
VAR _calc =
    CALCULATE (
        COUNTROWS ( myTable ),
        mytable[product] = "Required Product",
        ALLEXCEPT ( mytable, mytable[ID] )
    )
RETURN
    IF ( _calc >= 1, "True", "False" )

has p.PNG

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.