Forum Discussion
Problem with Row context
I have a report that has a bunch of columns on it and have a weird behavior that I cannot figure out what is going on. One of the formulas, the APF colum, is blank for all rows that are not at the lowest level of detail. I simplified the DAX expression to simply CountRows over a context. Below is the simple DAX expression
You can see in the image below that the APF column has a number in it on some of the rows at the lowest level, which is the correct number of rows I would expect. But if you look up the APF column the higher level groupings are all blank, which is why my more complex DAX expression is also failing. I don't understand how at the low level it has a count, but at the grouped up level it doesn't have the count.
Good to hear. What I learned from this is that only the first expression of the Calculate() is impacted by the context transition. That was not clear to me before.
13 Replies
- lbendlinSuper User
I don't think this is row context. Row context applies to the raw data tables and is generally accessed via calculated columns.
Try using variables
APF =
var v1 = SELECTEDVALUE ( 'VF APF Rate'[PlanAccountID] )
var v2 = SELECTEDVALUE ( 'VF APF Rate'[Product Code] )
var v3 = SELECTEDVALUE( 'VF APF Rate'[MinDate] )
var v4 = SELECTEDVALUE( 'VF APF Rate'[MaxDate] )return COUNTROWS(FILTER (ALL ( 'VF Demand Forecast' ),'VF Demand Forecast'[PlanAccountID] = v1&& 'VF Demand Forecast'[PrdId] = v2&& 'VF Demand Forecast'[Date] >= v3&& 'VF Demand Forecast'[Date] <= v4)That way you preserve the important parts of the filter context before you destroy it with ALL().