Hi everyone!
I'm working with sports data and trying to get some insights from it. My objective, here, is to have a clear view of the last game played between MYTEAM and the rival. Analyzing the points, I use the CALCULATE function to, automatically, get the points scored by the rival (the data is updated after every new game) with this function:
Riv_Pts/G_Last =
VAR _date = CALCULATE( MAX(GamesData[Date]), ALLSELECTED(GamesData))
RETURN CALCULATE( [Riv_Pts/G], GamesData[Date] = _date )
How do I expect that CALCULATE work? My expectation is to have the points of the last game, filtered. Then, be able to analyze these points using the different dimensions (columns).
This is working for most cases but, for a specific case (when there is no value of Situation column for the last date), CALCULATE is looking for the last game where the situation happened instead of returning zero or blank.
How could I fix/control this specific casuistry in my formula? Add you the pbix (in a Drive folder because I can't add the pbix directly, yet) to test and the examples below, to explain the casuistry.
Thank you so much for your time.
Example:
The Last Game for Competition = Comp3 is the "MYTEAM - RIVAL28" (it's the MAX Date for the Comp = 19/01/23). The first image is a example where it's working perfectly because there are rows where Situation = FastBreak.
But, in the following example, bearing in mind that, for the "MYTEAM - RIVAL28" game, there are no rows with Situation = HandOff, CALCULATE function is going to the previous game where there were rows for Situation = HandOff instead of returning 0 or blank (what I expected, bearing in mind there are no situations of HandOff).