Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not 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 you help with this?

 

i want it something like

 

Cumulative Sum 

800

1600

.

.

.

.

Screenshot (119).png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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 )
RETURN
SUMX ( Result, [Emp Hours Week] )
 
Thanks to @MFelix  for the solution! 😄

View solution in original post

7 REPLIES 7
smpa01
Super User
Super User

@Anonymous  this should give you what you need

_runningTotal =
CALCULATE (
    [Emp hours Week],
    FILTER (
        ALL ( 'Table'[WeekNum] ),
        'Table'[WeekNum] <= MAX ( 'Table'[WeekNum] )
    )
)
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

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 )
RETURN
SUMX ( Result, [Emp Hours Week] )
 
Thanks to @MFelix  for the solution! 😄
arvindsingh802
Super User
Super User

The solution 

arvindsingh802_0-1640869774663.png

EMP_Hour = CALCULATE(SUM('Table'[Hour]), FILTER('Table','Table'[Week] <>0))
 
EMP_Hour running total in Week =
CALCULATE(
    'Table'[EMP_Hour],
    FILTER(
        ALLSELECTED('Table'[Week]),
        ISONORAFTER('Table'[Week], MAX('Table'[Week]), DESC)
    )
)
 
If you need to show week 0 in your visual then enable Show Item with no data for week column
arvindsingh802_1-1640869887263.png

 

 


If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!
Proud to be a Super User!!
Anonymous
Not applicable

hi,

 

I used your formula and got this,still the same values

 

Screenshot (124).png

speedramps
Super User
Super 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,.
 
 

 

 

Anonymous
Not applicable

hi,

 

Cummulative =
VAR myweek = SELECTEDVALUE(Facts[Week])
RETURN
CALCULATE(
SUM(Facts[Emp Hours]),
ALL(Facts[Week]),
Facts[Week] <= myweek && Facts[Week] <> 0
)
 
The ISSUE for me is Emp Hours is A measure and not column. 
So SUM function takes only column as input.
how do i use emp hours week ( measure)?

In answer to your question "how do I use emp hours as a measure?"

 

It depend on the complexity of the measure.

It is somethign simple like 

emphours = SUM(Facts[Emp Hours])

 

then this will produce excatly the same answer as before

see   Click here to download PBIX 

 

 

Cummulative2 =
VAR myweek = SELECTEDVALUE(Facts[Week])
RETURN
CALCULATE(
[emphours]
ALL(Facts[Week]),
Facts[Week] <= myweek && Facts[Week] <> 0
)

 

 

how it works ....

a measure is not a stoire varible. it has to be recalculate in contect each time it is referenced.

So if you imbed a measure within CALCULATE and ALL context then it will alter the contect accordingly, unless your first measure has conflicting commands which the second cant override, 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors