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

Help building a query, many2many

I have a list of product ID's and the users that order certain products.  I am looking to find a count for the number of ID's that have one, the other, and both of certain users.  In reality, the user list is 18 names (2 different sets of 9 names).  

 

In this example:

Col - A - ID -> duplicated to reflect the product and the multiple users that access the product

Col - B - User -> interested in finding relationships between users and the products they use

Col - C - Result -> What I envision a simple operation would do to show only the relevant user data I am after

Col - D - Wanted -> The goal is to have the query return an answer based on the ID's 

 

To sum this up.  I want to know when certain configurations of any "User A" and any "User C" are occurring.  Furthermore, I want this information to be reflected for all cells with the same ID.  

 

power_bi_q.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This did the trick
 
Wanted =
VAR countr =
CALCULATE(
COUNTROWS(Table),
FILTER(Table,
Table[ID] =  EARLIER(Table[ID])
&& Table[Result] = EARLIER(Table[Result])
))
Return IF(countr > 1, "Both", BLANK())

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

This did the trick
 
Wanted =
VAR countr =
CALCULATE(
COUNTROWS(Table),
FILTER(Table,
Table[ID] =  EARLIER(Table[ID])
&& Table[Result] = EARLIER(Table[Result])
))
Return IF(countr > 1, "Both", BLANK())
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try this measure:

Wanted =
IF (
    MAX ( 'Table'[ID] )
        = CALCULATE (
            MAX ( 'Table'[ID] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[User] = 'Table'[Result]
                    && 'Table'[ID] IN FILTERS ( 'Table'[ID] )
            )
        ),
    "Both",
    BLANK ()
)

The result shows:

1.PNG

Hope this helps.

 

Best Regards,

Giotto Zhi

Greg_Deckler
Community Champion
Community Champion

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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
Top Kudoed Authors