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.
New to Power BI and been doing a bit of research on the product. Making good progress on my project but ran into brick wall on one calculation. I would like to see how many times two players have played together in a game. Here is my table layout:
.
GameId | PlayerName |
1 | QB |
1 | WR1 |
1 | WR2 |
1 | RB1 |
1 | TE |
2 | QB |
2 | WR1 |
2 | RB2 |
2 | WR3 |
2 | RB3 |
3 | QB |
3 | WR1 |
3 | RB3 |
3 | K |
3 | WR4 |
Here are the results I expect to get.
Combo - TimesPlayedTogher
QB/WR1 - 2
QB/RB1 - 1
QB/WR2 - 1
QB/K - 1
QB/TE - 1
QB/WR3 - 2
QB/RB2 - 1
QB/RB3 - 2
QB/WR4 - 1
I just can't seem to output this result with two players for the same game counted as one unit. Been playing around with several different measured formulas. Any thoughts?
Solved! Go to Solution.
Thank you good sir. I had all my data in a single table and when I tried mimic what you had done I got some bizaare results. I tried breaking up the data but no luck. But I was able to take my data and build off template you created. I'm still learning so maybe one day I'll figure out why my source data didn't work.
Hi @Anonymous
I had an initial look at this and it fits the Basket Analysis pattern:
https://www.daxpatterns.com/basket-analysis/
I created up a sample PBIX here showing how you could handle this:
Note that there is an inactive relationship between Games[PlayerName] and 'Player Secondary'[PlayerName Secondary].
Create these measures:
Times Played Together = CALCULATE ( DISTINCTCOUNT ( Games[GameId] ), CALCULATETABLE ( SUMMARIZE ( Games, Games[GameId] ), ALL ( Player ), USERELATIONSHIP ( Games[PlayerName], 'Player Secondary'[PlayerName Secondary] ) ) )
PlayerName < PlayerName Secondary = INT ( SELECTEDVALUE ( Player[PlayerName] ) < SELECTEDVALUE ( 'Player Secondary'[PlayerName Secondary] ) )
Combo = SELECTEDVALUE ( Player[PlayerName] ) & "/" & SELECTEDVALUE ( 'Player Secondary'[PlayerName Secondary] )
Hopefully that's useful as a start.
Regards,
Owen
Thank you good sir. I had all my data in a single table and when I tried mimic what you had done I got some bizaare results. I tried breaking up the data but no luck. But I was able to take my data and build off template you created. I'm still learning so maybe one day I'll figure out why my source data didn't work.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |