Forum Discussion
Anonymous
4 years agoNot applicable
power bi
Hi, I have a question, As you can see I want to calculate the Cumulative sum of Emp hours Week Except Week 0. and Emp hours week is a measure ( not a coloumn ) How do I achieve that? Can ...
- Anonymous4 years ago
HI ALL,
the solution is :
Avrg Emp Hours =VAR WEEKNUMBER =MAX ( 'Yearly Data'[WeekNum] )VAR temp =SUMMARIZE (ALL ( 'Yearly Data' ),'Yearly Data'[WeekNum],"CumulativeTotal", [Emp Hours Week])VAR Result =FILTER ( temp, 'Yearly Data'[WeekNum] <= WEEKNUMBER && 'Yearly Data'[WeekNum] > 0 )RETURNSUMX ( Result, [Emp Hours Week] )Thanks to MFelix for the solution! 😄
speedramps
4 years agoSuper User
Try this Click here to download PBIX
How is works ...
Cummulative =
VAR myweek = SELECTEDVALUE(Facts[Week])
RETURN
CALCULATE(
SUM(Facts[Emp Hours]),
ALL(Facts[Week]),
Facts[Week] <= myweek && Facts[Week] <> 0
)
myweek gets the current week with SLECETDVALUE,.
CALCULATE allows you to overrides the default weeky by week filter.
SUM aggregates the hours.
ALL overrides the default weeky by week filter.
Facts[Week] <= myweek aggregates upto and inlcusing the current week.
Facts[Week] <> myweek ignores week zero as requested,.