Forum Discussion
Sum for next row based on condition
- Anonymous2 years ago
Hi tranguyen ,
Try below:
_Value = MAX('Table'[Value]) Measure = var _v = [_Value] var _pre = ADDCOLUMNS('Table',"pre",SUMX(FILTER(ALL('Table'),[Rank]=EARLIER('Table'[Rank])-1),[_Value])) RETURN IF(_v<=2,"blank",IF(SUMX(_pre,[pre])<=2,_v+SUMX(_pre,[pre]),_v))Hope it helps!
Best regards,
Community Support Team_ Scott ChangIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi tranguyen ,
I made simple samples and you can check the results below:
Measure = var _v = MAX('Table'[Value])
var _pre = ADDCOLUMNS('Table',"pre",SUMX(FILTER(ALL('Table'),[Rank]=EARLIER('Table'[Rank])-1),[Value]))
RETURN IF(_v<=2,"blank",IF(SUMX(_pre,[pre])<=2,_v+SUMX(_pre,[pre]),_v))
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- tranguyen2 years agoFrequent Visitor
Thanks for helping. But Value in this case is a measure, When I used max([Value]) It showed:
- The MAX function only accepts a column reference as the argument number 1.- Anonymous2 years agoNot applicable
Hi tranguyen ,
Try below:
_Value = MAX('Table'[Value]) Measure = var _v = [_Value] var _pre = ADDCOLUMNS('Table',"pre",SUMX(FILTER(ALL('Table'),[Rank]=EARLIER('Table'[Rank])-1),[_Value])) RETURN IF(_v<=2,"blank",IF(SUMX(_pre,[pre])<=2,_v+SUMX(_pre,[pre]),_v))Hope it helps!
Best regards,
Community Support Team_ Scott ChangIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.