Forum Discussion
tranguyen
2 years agoFrequent Visitor
Sum for next row based on condition
Hi everyone. I am a fresher in Power BI. Please help to look at 2 pictures below. - Week wash is a column - Rank is a column that was created by week wash and month - Distinctcustomerbycategory...
- 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.
tranguyen
2 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.
Anonymous
2 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 Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.