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.
Background - lots of programming experience - but new to Power BI. Playing around with some sports data just to get my feet wet.
I'm assuming this should be easy, but I've banged my head against it for a couple of days.
I have two tables:
Teams
-----
TeamID
TeamName
Games
--------
GameID
GameDate
HomeTeamID
AwayTeamID
How would you go about creating a visualization that represents a schedule in the form of:
GateDate HomeTeamName AwayTeamName
I don't need every detail explained, just the major steps.
Solved! Go to Solution.
Yes, indeed, like all rookies to DAX, you do miss something simple. I wish you were able to understand this simple solution.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
thats many way but i get solution from below method
EVALUATE
SUMMARIZECOLUMNS('games'[game date],
"HomeTeamname",CALCULATE(VALUES(team[teamname]),
TREATAS(VALUES(games[hometeam id]),team[team id])
),
"awayTeamname", CALCULATE(VALUES(team[teamname]),
TREATAS(VALUES(games[awayteam id]),team[team id])
)
)
we need to use Treats to Change Data lineage of game's table to Team Table
which create Virtual Relationship and through it we able to filter Team table
If you Want to know more about it please visit Here .
Simple enough
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@CNENFRNL wrote:Simple enough
- Unpivot HomeTeamID and AwayTeamID
- Create relationship
That's what I thought the answer was. But I still can't get from there to a visualization in the form of a table with the columns:
GameDate HomeTeamName AwayTeamName
Can you help me get from the unpivoted table to that visualization? I know I'm probably missing something simple, but I keep getting stuck.
Yes, indeed, like all rookies to DAX, you do miss something simple. I wish you were able to understand this simple solution.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
thats many way but i get solution from below method
EVALUATE
SUMMARIZECOLUMNS('games'[game date],
"HomeTeamname",CALCULATE(VALUES(team[teamname]),
TREATAS(VALUES(games[hometeam id]),team[team id])
),
"awayTeamname", CALCULATE(VALUES(team[teamname]),
TREATAS(VALUES(games[awayteam id]),team[team id])
)
)
we need to use Treats to Change Data lineage of game's table to Team Table
which create Virtual Relationship and through it we able to filter Team table
If you Want to know more about it please visit Here .
Can I ask a followup question? I've played around with the solution you provided, and I'm still struggling to understand how the CALCULATE FUNCTION works in this expression.
Specifically I'm unclear on where the context comes from such that this measure returns the correct team. Does the table visual create a context for each row that the measure runs inside of?
Em.... impossible to explain it in several sentences. CALCULATE() is the grail of DAX. Crack down on it, then you (almost) master DAX. Your DAX journey starts from CALCULATE() and the ultimate goal is also CALCULATE().
Tricky thing is that CALCULATE() functions like a 10-layer wrapper; and above all, the most annoying thing is that, up till now, there's no handy debug tool allowing DAX user to debug step-by-step. Tons of abstract details like context transition, filters modification, filtering propagation etc. happen in a sandbox.
Enjoy DAX!
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hello @cjd72consulting,
1. Create a relationship between the Teams table and the Games table based on the TeamID.
2. Create a new measure in the Games table that concatenates the HomeTeamName and AwayTeamName columns with a hyphen (-) separator.
Matchup = CONCATENATE(Games[HomeTeamName], " - ", Games[AwayTeamName])
3. Create a new table visual and add the following columns in this order:
4. For the HomeTeamName and AwayTeamName columns, expand the Teams table and select the TeamName column.
5. In the Values section of the visual, add the Matchup measure from the Games table.
Hope this helps.
Thanks Sahir,
I may very well be missing something, but I don't think this works.
My Games Table has Team ID's, not Team Names, so your step 2 doesn't seem to make sense?
@cjd72consulting, I might have misinterpretted your tables. Can you please provide more detail on:
Are these additional tables or do they relate to the Teams table?
HomeTeamID and AwayTeamID are foreign keys referencing the Primary key TeamID in the Teams table
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 |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
129 | |
106 | |
106 | |
86 | |
72 |