Forum Discussion
Problem with Row context
- 6 years ago
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.
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
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] )
- pcavacas6 years agoHelper I
The problem with what you are saying here, is that the actual calculation is a SumX over the APF Rates table, so I can't grab the values into variables.
- lbendlin6 years agoSuper User
SELECTEDVALUE() expects a single value in the filter context. You don't have that in a group.
- pcavacas6 years agoHelper I
I realize that SelectedValue takes a single value, but it is in a Sumx, the below DAX is closer to the real formula that I'm using. You can see that the SelectedValue is still valid because it is part of the SumX iterator.
SUMX ('VF APF Rate','VF APF Rate'[Rate]* CALCULATE ([Latest Estimate Revenue],FILTER (ALL ( 'VF Demand Forecast' ),'VF Demand Forecast'[PlanAccountID] = SELECTEDVALUE ( 'VF APF Rate'[PlanAccountID] )&& 'VF Demand Forecast'[PrdId] = SELECTEDVALUE ( 'VF APF Rate'[Product Code] )&& 'VF Demand Forecast'[Date] >= SELECTEDVALUE( 'VF APF Rate'[MinDate] )&& 'VF Demand Forecast'[Date] <= SELECTEDVALUE( 'VF APF Rate'[MaxDate] ))))