Forum Discussion
Add specific rows
- 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 Properly follow the code and bracket as per my given DAX. I don't know why you close all MAX and SUM bracket's at the end. Follow my code step by step and open and close the bracket accordingly.
Else, copy paste that DAX here instead of sharing screen shot.
Sorry, my bad. Below is the error-free DAX, but looks like it is printing the result of UID=5 to all the rows.
Result = SWITCH(True(),
MAX(TableA[UID])=1,SUM(TableA[values2]),
MAX(TableA[UID])=2,SUM(TableA[Values2]),
MAX(TableA[UID])=3,SUM(TableA[values1])+SUM(TableA[values2]),
MAX(TableA[UID])=4,SUM(TableA[values2]),
MAX(TableA[UID])=5,2*(SUM(TableA[values1])+SUM(TableA[Values2])),
SUM(TableA[Values2]))