Forum Discussion
Anonymous
4 years agoNot applicable
Add specific rows
Hi Folks, I would like to add specific columns as shown in the below attached picture. For UID = 1, Values2 For UID = 2, Values 2 For UID =3, Values1+Values2 For UID =4, Values2 For UID =5, ...
- 4 years ago
Ah, I wasn't quite understanding where that number came from but I see now.
Since it depends on a different row, you'd need to do something a bit more like this:
Calculated Column = VAR _UID = TableA[UID] VAR _Vals1 = TableA[values1] VAR _Vals2 = TableA[values2] VAR _Sum3 = SUMX ( FILTER ( TableA, TableA[UID] = 3 ), TableA[values1] + TableA[values1] ) RETURN SWITCH ( _UID, 1, _Vals2, 2, _Vals2, 3, _Vals1 + _Vals2, 4, _Vals2, 5, _Sum3 + _Vals1 + _Vals2, _Vals2 )
Anonymous
4 years agoNot applicable
AlexisOlson , The result for UID=5 doesn't match with the Expected Result. I see you have multiplied with 2. But for UID5, it is the SUM(Value1(UID=5)+Value2(UID=5) + CalculatedSum(UID=3))
So it would be 1000 + 1500 + 200 = 2700.
Here 200 is the Calculated sum for UID=3.
AlexisOlson
Super User
4 years agoAh, I wasn't quite understanding where that number came from but I see now.
Since it depends on a different row, you'd need to do something a bit more like this:
Calculated Column =
VAR _UID = TableA[UID]
VAR _Vals1 = TableA[values1]
VAR _Vals2 = TableA[values2]
VAR _Sum3 =
SUMX (
FILTER ( TableA, TableA[UID] = 3 ),
TableA[values1] + TableA[values1]
)
RETURN
SWITCH (
_UID,
1, _Vals2,
2, _Vals2,
3, _Vals1 + _Vals2,
4, _Vals2,
5, _Sum3 + _Vals1 + _Vals2,
_Vals2
)