Forum Discussion
Understanding evaluation context
- 2 years ago
I have finally found the answer to "my riddle" in the following post:
This above-mentioned post deals with very similar problem as I was struggling with and refers to the following very clear article on auto-exist behaviour of SUMMARIZECOLUMNS function in some specific situations. It exactly answers to the questions raised in my post.
https://www.sqlbi.com/articles/understanding-dax-auto-exist/
Hi Anonymous
First of all, thank you very much for your reply and effort to help me. Secondly, please apologize my late reaction.
Unfortunately, I have to say that even if I went through your email again and again I am still confused why "my" measure Test works like it works (of course this is my fault, not yours at all).
You wrote that the value 3 I get is calculated separately for A and B, and then added, like this(0+3=3). From what I know about DAX this "step-by-step" mechanism of calculation is somtehing that I have never read or heard of. But it is not so important at this moment.
My understading of how evaluation context in my measure Test is build up is as follows. Assume that slicer for PERIOD filters A and B, and slicer for SUBJECT_CODE filters 2 to 6 (situation like in the last picture of your email) and that we calculate measute for PERIOD 6 in line chart or table visual :
- So, the outer filter context consist of PERIOD = {2, 3, 4, 5, 6} (from slicer), PERIOD = {6} (from visual), which intersects to PERIOD = {6}, and SUBJECT_CODE = {A, B} (from slicer)
- MaxDate calculated in the outer filter context then results in 6
- Condition Data[PERIOD] <= MaxDate inside CALCULATE returns PERIOD = {2, 3, 4, 5, 6} and this inner filter context for PERIOD overwrites outer context (PERIOD = {6})
- CALCULATE does not change filter context for SUBJECT_CODE (no condition or modifier regarding SUBJECT_CODE is present in it), so the outer filter context SUBJECT_CODE = {A, B} from slicer is stil valid
- The final filter context in which measure Test is calculated is PERIOD = {2, 3, 4, 5, 6} and SUBJECT_CODE = {A, B}, which should filter 7 rows of Data table {(A, 2), (A, 3), (A, 4), (A, 5), (B, 4), (B, 5), (B, 6)}
Of course, there is some point in my chain of reasoning which is wrong, because result is not 7 but 3. Would you, please, be able to pinpoint where exactly it is.
Finaly, I would like to ensure you that I will accept your solution, even if you decide to not answer to my second email.
Best regards
Viktor
I have finally found the answer to "my riddle" in the following post:
This above-mentioned post deals with very similar problem as I was struggling with and refers to the following very clear article on auto-exist behaviour of SUMMARIZECOLUMNS function in some specific situations. It exactly answers to the questions raised in my post.
https://www.sqlbi.com/articles/understanding-dax-auto-exist/