Forum Discussion
MAX value in direct query mode
- 1 year ago
Hi Zuzana ,
In Direct Query mode, if you're trying to show the maximum category number for each child ID across all related parent ID rows, your current DAX measure isn't correctly removing the row-level filter context. To achieve the desired result—where each row displays the same maximum category number per child ID—you should revise the measure to explicitly remove filters on everything except the child ID. You can use the ALLEXCEPT function to achieve this. Here's the corrected measure:
#Max Cat = CALCULATE( MAX('your_table'[category number]), ALLEXCEPT('your_table', 'your_table'[child ID]) )This version ensures that the measure returns the same maximum value of category number for all rows sharing the same child ID, regardless of other filters in the table. Just replace 'your_table' with the actual name of your table. This approach works in Direct Query mode and avoids the pitfalls of SELECTEDVALUE not resolving correctly due to row context limitations.
Best regards,
Hi Zuzana ,
In Direct Query mode, if you're trying to show the maximum category number for each child ID across all related parent ID rows, your current DAX measure isn't correctly removing the row-level filter context. To achieve the desired result—where each row displays the same maximum category number per child ID—you should revise the measure to explicitly remove filters on everything except the child ID. You can use the ALLEXCEPT function to achieve this. Here's the corrected measure:
#Max Cat =
CALCULATE(
MAX('your_table'[category number]),
ALLEXCEPT('your_table', 'your_table'[child ID])
)
This version ensures that the measure returns the same maximum value of category number for all rows sharing the same child ID, regardless of other filters in the table. Just replace 'your_table' with the actual name of your table. This approach works in Direct Query mode and avoids the pitfalls of SELECTEDVALUE not resolving correctly due to row context limitations.
Best regards,
Hi DataNinja777 ,
Thank you very much for your solution. This seems to be working well. 🙂
You saved me!
Have a wonderful weekend.