Forum Discussion
Filter Context
Hi,
Thanks for your reply.
It seems as if I can't do the following: TREATAS(VALUES('Position Lookup'[Position Group]), 'Position Lookup'[Position Group]).
This is becuase the 'Position Lookup'[Position Group]) is not a TableNameOrColumnName. It is a Measure.
Any solutions to this?
Thanks
Ah, I understand the challenge now. If Position Lookup is a measure and not a direct column reference, then you cannot use it directly within the TREATAS function as you've tried.
To address this, you can create a new calculated column in your data model (perhaps within the 'Player Reference' table) that uses the Position Lookup measure to get the Position Group for each player. Once you have this new calculated column, you can then use it to filter or adjust your measures.
Here's a step-by-step guide:
Create a New Calculated Column:
You can create a new calculated column in the 'Player Reference' table that fetches the 'Position Group' based on the 'Player Name' using the Position Lookup measure. The formula would look something like:
Position Group Column = [Position Lookup]
When you add this column to your table, it will dynamically fetch the 'Position Group' for each player name based on the measure's logic.
Modify Your Measure:
After creating the new calculated column, you can modify your DAX measure to incorporate this column for filtering:
Positional Max CMJ Jump Height =
CALCULATE(
MAX(CMJ[Jump Height (Imp-Mom) [cm]]),
ALL('CMJ'),
'CMJ'[Player Name] IN VALUES('Player Reference'[Player Name]),
'CMJ'[Position Group] = 'Player Reference'[Position Group Column]
)
Here:
- We are still using the CALCULATE function to adjust the filter context.
- The 'CMJ'[Position Group] = 'Player Reference'[Position Group Column] condition ensures that the calculation considers the 'Position Group' based on the new calculated column from the 'Player Reference' table.
By creating the calculated column, you essentially move the logic from a measure to the data model, making it easier to incorporate within your DAX formulas.