Forum Discussion
GROUPBY Context Transition
- 8 years ago
RobertSlattery- I may be off-base here but I believe you have a fundamental misunderstanding of how measures function. For measures in DAX, the starting filter context is ALWAYS the context of the visual. So, if you use a measure in a single row, that's the starting context of the measure unless you change it by wrapping the calculation in a CALCULATE or CALCULATETABLE and using something like an ALL, ALLEXCEPT or other type of filter that fundamental and specifically changes the original filter context.
Your first calculation doesn't do any of that. Your first calculation starts with a filter context of a single row. So, that is the starting filter for the GROUPBY, which is not a context/filter changing function. It is just going to do it's thing on whatever data it has access to based upon the starting context/filter.
Therefore, it is really, really difficult to see exactly what is going on with your functions with what I would consider 1/3rd of the critical information. You have presented the calculations, which is good but we are missing the context in which you are placing them (your use of them in visuals, what visuals, what other information is around them, etc.) And the actual data or a sample of data that is being used so that we can replicate the issue/behavior without recreating it all.
First question, can we get sample data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Second question, where in the documentation do you read that row context is not passed through? https://msdn.microsoft.com/en-us/query-bi/dax/groupby-function-dax That doesn't really make sense to me and I don't see it in the documentation.
- RobertSlattery8 years agoResponsive Resident
Hi Greg_Deckler, Yes I know, but since I have a work-arround, I'll have to post an example later when I get time. Having said that, I would have thought that context transition or not on a particular function - outside of a Calculate - would be a straight-up knowledge thing. (And since MS doesn't bother to document properly, we have to create knowledge by posting questions.)
Most functions do not apply a context transition outside of Calculate or CalculateTable so I find it surprising that GROUPBY does, especially given the rmarks in the documentation here
I don't know where to look in the docs bout if FILTER fails silently on a table dynamically created within a measure but again this is a specific question about a specific scenario that doesn't require data I think.
- Greg_Deckler8 years agoCommunity Champion
RobertSlattery- I may be off-base here but I believe you have a fundamental misunderstanding of how measures function. For measures in DAX, the starting filter context is ALWAYS the context of the visual. So, if you use a measure in a single row, that's the starting context of the measure unless you change it by wrapping the calculation in a CALCULATE or CALCULATETABLE and using something like an ALL, ALLEXCEPT or other type of filter that fundamental and specifically changes the original filter context.
Your first calculation doesn't do any of that. Your first calculation starts with a filter context of a single row. So, that is the starting filter for the GROUPBY, which is not a context/filter changing function. It is just going to do it's thing on whatever data it has access to based upon the starting context/filter.
Therefore, it is really, really difficult to see exactly what is going on with your functions with what I would consider 1/3rd of the critical information. You have presented the calculations, which is good but we are missing the context in which you are placing them (your use of them in visuals, what visuals, what other information is around them, etc.) And the actual data or a sample of data that is being used so that we can replicate the issue/behavior without recreating it all.
- RobertSlattery8 years agoResponsive Resident
Youre right Greg_Deckler, the context is there regardless of the Calculate. I'm a bit confused about this, given all the mysterious handwaving about Calculate efecting a ~Context Transition~. SMH.
OK, thanks again.