Forum Discussion

pablopablo's avatar
pablopablo
Frequent Visitor
5 years ago
Solved

Help with running cumulative count

Hi,

 

I have the following code which correctly gives me a running total based on a week number of total jobs opened per week. However, i need to amend so it does not count those jobs which have already closed before or during the current week.

 

I also need to filter out only those records where a status does not equal "Cancelled"

 

So if my data looks like this

 

Job NoWeek OpenedWeek Closed
00114
00227
00325
00449
00556

 

I expect my measure to return "Total Records per week"

 

Week 1 - 1

Week 2 - 3

Week 3 - 3

Week 4 - 3 (as the first record closed in week 4)

Week 5 - 4 (as the third record closed in week 5)

Week 5 - 4

Week 6 - 2

 

 

 

Measure = 
CALCULATE (
    COUNT ( 'Live_Roles_Feed'[Job no.] ),
    FILTER (
        ALLSELECTED ( 'Live_Roles_Feed' ),
        'Live_Roles_Feed'[Week_Opened] <= MAX ( 'Calendar'[Week] )
    )
)

 

 

 

  • Hi pablopablo ,

     

    Try this.

    Measure = 
    VAR x = 
    CALCULATE(
        COUNT(Sheet10[Job No]),
        FILTER(
           Sheet10,
            [Week Opened] <= MAX('Calendar'[Week]) && [Week Closed] > MAX('Calendar'[Week])
        )
    )
    RETURN
    x

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

5 Replies