Forum Discussion
Re: Power BI- Need help with NRR Dax calculation from team1/team2 columns
Hi,
I’m currently building an IPL Points Table in Power BI using a single match-level dataset where each row contains both team1 and team2, along with their respective runs, overs, and match results.
I’ve successfully created measures for Matches (M), Wins (W), Losses (L), No Results (NR), and Points (PTS), and they are working correctly.
However, I’m facing an issue with calculating FOR, AGAINST, and Net Run Rate (NRR).
The problem is that each match stores stats separately for team1 and team2 (like team1_runs, team2_runs, team1_overs, team2_overs). While calculating NRR, I need to correctly aggregate:
Runs scored and overs faced by a team
Runs conceded and overs bowled against that team
Right now, my calculation is not correctly distinguishing between when a team appears as team1 vs team2, which is causing incorrect FOR, AGAINST, and NRR values.
To clarify:
If a team is in team1 → use team1_runs and team1_overs
If a team is in team2 → use team2_runs and team2_overs
Similarly, AGAINST should reverse this logic
After that, both sides should be summed together to get the total runs and overs for accurate calculation
I understand the logic conceptually, but I’m struggling to implement it cleanly in DAX without errors or incorrect aggregation.
What would be the best way to handle this kind of dual-column structure (team1/team2) for accurate NRR calculations in Power BI?
Image: without NRR
Sample data:
| match_id | season_id | city | match_date | venue | toss_winner | team1 | team2 | toss_decision | match_winner | win_by_runs | win_by_wickets | player_of_match | result | stage | team1_runs | team2_runs | team1_wickets | team2_wickets | team1_overs | team2_overs | superover_winner |
| 1473508 | 2025 | New Chandigarh | 5/29/2025 | Maharaja Yadavindra Singh International Cricket Stadium, Mullanpur | Royal Challengers Bengaluru | Punjab Kings | Royal Challengers Bengaluru | field | Royal Challengers Bengaluru | 8 | 8475 | win | Qualifier 1 | 101 | 106 | 10 | 2 | 14.1 | 10 | ||
| 1485779 | 2025 | Jaipur | 5/24/2025 | Sawai Mansingh Stadium, Jaipur | Delhi Capitals | Punjab Kings | Delhi Capitals | field | Delhi Capitals | 6 | 10070 | win | Unknown | 206 | 208 | 8 | 4 | 20 | 19.3 | ||
| 1473497 | 2025 | Jaipur | 5/18/2025 | Sawai Mansingh Stadium, Jaipur | Punjab Kings | Punjab Kings | Rajasthan Royals | bat | Punjab Kings | 10 | 3495 | win | Unknown | 219 | 209 | 5 | 7 | 20 | 20 | ||
| 1473495 | 2025 | Dharamsala | 5/8/2025 | Himachal Pradesh Cricket Association Stadium, Dharamsala | Punjab Kings | Punjab Kings | Delhi Capitals | bat | rescheduled | Unknown | 122 | 0 | 1 | 0 | 10.1 | 0 | |||||
| 1473491 | 2025 | Dharamsala | 5/4/2025 | Himachal Pradesh Cricket Association Stadium, Dharamsala | Lucknow Super Giants | Punjab Kings | Lucknow Super Giants | field | Punjab Kings | 37 | 3747 | win | Unknown | 236 | 199 | 5 | 7 | 20 | 20 |
What I need:
A Points Table that shows for each team (across selected season):
| POS | Rank based on Points and NRR |
| Team | Unique team name (from both team1 and team2) |
| M | Count of matches played (exclude rescheduled) |
| W | Count of matches won (win + tie with superover) |
| L | Count of matches lost |
| NR | Count of abandoned or no result matches |
| PTS | (W × 2) + (NR × 1) |
| FOR | Total runs scored / Total overs faced (format: "2447/246.4") |
| AGAINST | Total runs conceded / Total overs bowled |
| NRR | FOR run rate - AGAINST run rate |
Any guidance or best practices would be really helpful.
Thank you.
2 Replies
- Juan-Power-bi
Super User
Hi my friend
The problem here is that your data structure isn't great for this kind of calculation — having team1/team2 side by side makes DAX really awkward. The cleanest fix is to unpivot the data in Power Query first.
Create a new table that has one row per team per match, like this:
match_idteamruns_scoredovers_facedruns_concededovers_bowled1Punjab Kings10114.1106101RCB1061010114.1
You can do this in Power Query by duplicating the matches table and appending two versions — one where team = team1 (using team1 stats for scored, team2 stats for conceded), and one where team = team2 (flipped). Then append both together.
Once you have that structure, all your NRR measures become straightforward SUM operations — no more IF(team = team1, ..., ...) gymnastics in DAX. - AmiraBedh
Super User
Hello muhammedswaliha !
Thank you for posting on MS Fabric community !
I totally agree with Juan-Power-bi .
What you have done does not work because each team stats are split across 2 different column sets so a normal measure cannot just sum one column for a team.
So you need to create a table where each match becomes 2 rows one row for team1 and one row for team2.
then every row already has the rest of the columns
After that, DAX becomes simple. I created this table and you can find the solution attached in the pbix file.
PointsTableBase =
VAR Team1Rows =
SELECTCOLUMNS(
Matches,
"match_id", Matches[match_id],
"season_id", Matches[season_id],
"match_date", Matches[match_date],
"result", Matches[result],
"stage", Matches[stage],
"Team", Matches[team1],
"Opponent", Matches[team2],
"RunsScored", Matches[team1_runs],
"OversFaced", Matches[team1_overs],
"RunsConceded", Matches[team2_runs],
"OversBowled", Matches[team2_overs],
"MatchWinner", Matches[match_winner],
"SuperOverWinner", Matches[superover_winner]
)
VAR Team2Rows =
SELECTCOLUMNS(
Matches,
"match_id", Matches[match_id],
"season_id", Matches[season_id],
"match_date", Matches[match_date],
"result", Matches[result],
"stage", Matches[stage],
"Team", Matches[team2],
"Opponent", Matches[team1],
"RunsScored", Matches[team2_runs],
"OversFaced", Matches[team2_overs],
"RunsConceded", Matches[team1_runs],
"OversBowled", Matches[team1_overs],
"MatchWinner", Matches[match_winner],
"SuperOverWinner", Matches[superover_winner]
)
RETURN
UNION(Team1Rows, Team2Rows)