March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I'm working with a NBA Dataset.
I have a table showing the season, where a Season as an ID which is the starting year of the season (e.g. for season 2023/24 the ID is 2023).
I would like to show, for a given season, player averages related to the previous one.
I created the measure highlited below, that takes the average minutes overall (it's another measure) and calculates for the previous season of the selected one:
But the measure is not shown and I think that the reason is that the filter context of each row has the season set to the selected one, while the measure takes the values of another season.
How can I correct the measure to get the desired result?
Solved! Go to Solution.
Sure:
'NBA season' is the dimension table of the seasons (just a plain list of "Season" / "SeasonID").
Hi @fpennisi ,
Thank you for the clarification. I encountered a similar issue where the previous month's values didn’t appear when the current month filter was applied in the row fields. I believe the formula below will resolve this issue.
EoPS MIN Previous Season =
VAR CurrentSeason = SELECTEDVALUE('NBA season'[Season ID])
VAR PreviousSeason = CurrentSeason - 1
RETURN
CALCULATE(
[MIN],
FILTER(
ALL('NBA season'),
'NBA season'[Season ID] = PreviousSeason
)
)
The reason the previous formula returned blank rows is that when you use a matrix visual with the current season in the row field, Power BI automatically applies a filter to show only the current season. This means that for each row in the visual, only data for the selected season is considered. The filter context created by the visual restricts the data to the specific season in that row.
Your original formula was constrained by this filter context, which applied only to the current season.
Best regards,
Hi @fpennisi ,
To evaluate your formula, could you please share the measures [Selected season] and [MIN] with us?
Best regards,
Sure:
'NBA season' is the dimension table of the seasons (just a plain list of "Season" / "SeasonID").
It worked perfectly!
I guessed it was for the reason you explained and a tried a couple of measures with ALL or REMOVEFILTERS, but I wasn't able to let them work.
Thank you!
Hi @fpennisi ,
Thank you for the clarification. I encountered a similar issue where the previous month's values didn’t appear when the current month filter was applied in the row fields. I believe the formula below will resolve this issue.
EoPS MIN Previous Season =
VAR CurrentSeason = SELECTEDVALUE('NBA season'[Season ID])
VAR PreviousSeason = CurrentSeason - 1
RETURN
CALCULATE(
[MIN],
FILTER(
ALL('NBA season'),
'NBA season'[Season ID] = PreviousSeason
)
)
The reason the previous formula returned blank rows is that when you use a matrix visual with the current season in the row field, Power BI automatically applies a filter to show only the current season. This means that for each row in the visual, only data for the selected season is considered. The filter context created by the visual restricts the data to the specific season in that row.
Your original formula was constrained by this filter context, which applied only to the current season.
Best regards,
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
28 | |
21 | |
20 | |
13 | |
10 |