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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Elzzie
Frequent Visitor

Check column from another table if it contains two values, and return a different string as result

Hi community,

I'm quite new to powerbi, and have a specific usecase I cannot figure out. I hope you can help me out here. 

I have the following two tables:

Event

EventIDEventName
1Birthday
2Wedding
3Party


Guest

GuestEventIDGuestLocation
11Outside
21Outside
32Inside
42Inside
53Inside
63Outside


The two tables are related through EventID. What I want as a result is to have an extra column in table "Event", which checks the location of the guests that are present at a specific EventID. Since for EventID 3, there are 2 different locations, I want to return that as "Both". I'm searching for the following result: 

EventIDEventNameGuestLocation
1BirthdayOutside
2WeddingInside
3PartyBoth


In my current situation I have two possible locations, but in the future this might be 3 or 4. So if that could be taken into account, that would be really nice. If that is really difficult I'm happy with a solution for two locations. 

I'm looking for a solution in DAX.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Elzzie PBIX is attached below signature.

GuestLocation = 
    VAR __Table = SUMMARIZE( RELATEDTABLE(Guest), [GuestLocation] )
    VAR __Rows = COUNTROWS( __Table )
    VAR __Result = 
        IF( 
            __Rows = 1,
            MAXX( __Table, [GuestLocation] ),
            "Multiple (" & __Rows & ")"
        )
RETURN
    __Result


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

View solution in original post

2 REPLIES 2
Elzzie
Frequent Visitor

@Greg_Deckler,
Thank you so much for this, my projectmanager will be very happy on Monday. 

It is not giving back the strings I would like, but I fixed that with another column matching the different options to the corresponding string I need. 

Enjoy your weekend!

Greg_Deckler
Community Champion
Community Champion

@Elzzie PBIX is attached below signature.

GuestLocation = 
    VAR __Table = SUMMARIZE( RELATEDTABLE(Guest), [GuestLocation] )
    VAR __Rows = COUNTROWS( __Table )
    VAR __Result = 
        IF( 
            __Rows = 1,
            MAXX( __Table, [GuestLocation] ),
            "Multiple (" & __Rows & ")"
        )
RETURN
    __Result


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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.