← All challenges

S1 · Row-level security · about 10 min

One Team Only

easy

The Harbor Hawks coach is getting access to the league report. They must see only their own team: its games, its runs, and only Harbor Hawks in the team list. Everyone else keeps seeing the whole league, so this needs a role, not a page filter.

Your task

Create a role named Harbor Hawks that limits the model to the Harbor Hawks (TeamID 1). Check it with Modeling > View as. Do not change any relationship.

What the grader checks

You see the situations, not the expected numbers. The expected values are computed live from your file and the source data.

  • T1Runs by team
    As the Harbor Hawks role: a table with one row per team and total runs.
  • T2Games by team
    As the Harbor Hawks role: number of games per team.
  • T3Runs per game, 2024
    As the Harbor Hawks role: runs divided by games, Season slicer set to 2024.
  • T4Team list
    As the Harbor Hawks role: how many teams a Team slicer would list.

Stuck?

Open one hint at a time.

Hint 1

A role filter is a DAX condition on one table. Rows that fail it disappear for the role's members, and so does everything the relationships filter from that table.

Hint 2

Open Model view and follow the arrows. A filter on Players reaches Batting, but does it reach Games? Which table sits above both Games and Batting?

Hint 3 (near-answer)

Put the filter on Teams: Modeling > Manage roles > New, name it Harbor Hawks, select Teams and enter Teams[Team] = "Harbor Hawks". Then use View as to check every table.

Show the editorial

Solve it first if you can: the editorial gives the answer away.

The trap

Filtering Players[TeamID] = 1 feels right, because the coach wants their own players. Batting is filtered through Players, so the runs look correct. But Games is not related to Players, so games per team, runs per game and the team list still show the whole league. Filtering Games[TeamID] gets every number right but still lists all six teams in a slicer.

The fix

Filter the Teams table: Teams[Team] = "Harbor Hawks" (or Teams[TeamID] = 1).

Why it works

A role's filter travels along relationships exactly like a slicer, in the direction of the arrows. Teams filters Games, and Games filters Batting, so one filter on Teams secures the team list and every fact below it. Players is a side branch: a filter there only reaches Batting.

Put a role's filter on the table at the top of the chain, then use View as to check that every table shrinks, not only the one you filtered.