Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
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
| EventID | EventName |
| 1 | Birthday |
| 2 | Wedding |
| 3 | Party |
Guest
| Guest | EventID | GuestLocation |
| 1 | 1 | Outside |
| 2 | 1 | Outside |
| 3 | 2 | Inside |
| 4 | 2 | Inside |
| 5 | 3 | Inside |
| 6 | 3 | Outside |
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:
| EventID | EventName | GuestLocation |
| 1 | Birthday | Outside |
| 2 | Wedding | Inside |
| 3 | Party | Both |
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.
Solved! Go to Solution.
@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
@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!
@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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 40 | |
| 37 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 67 | |
| 34 | |
| 33 | |
| 30 |