Forum Discussion

iangilsenan's avatar
iangilsenan
Frequent Visitor
6 years ago
Solved

Count values cumulatively over time

We are using a few Power BI Reports in our high schools and are looking for help with counting values cumulatively over time in a Matrix table in a Power BI report.

I’ve provided simplified tables below and our desired outcome.

PUPIL TABLE

PupilId

Name

1

Paul Smith

2

Lisa White

3

John Brown

 

Each pupil has an attendance mark record each day

ATTENDANCE TABLE

PupilID

MarkDate

Mark

Description

Category

1

01/09/2019

P

Present

Present

2

01/09/2019

P

Present

Present

3

01/09/2019

P

Present

Present

1

02/09/2019

P

Present

Present

2

02/09/2019

M

Medical

Absent

3

02/09/2019

P

Present

Present

1

03/09/2019

P

Present

Present

2

03/09/2019

I

Illness

Absent

3

03/09/2019

P

Present

Present

 

We created a measure which counts the present marks:

COUNTROWS(FILTER(ATTENDANCE,[Category]="Present"))

But when we use this as the Value in a Matrix table (with MarkDate as column header and Name as Row Header), it just returns a count on each day.

We need the Present marks to be counted cumulatively over time, i.e.

01/09/2019

01/09/2019 to 02/09/2019

01/09/2019 to 03/09/2019

Like this example:

Name

01/09/2019

02/09/2019

03/09/2019

Paul Smith

1

2

3

Lisa White

1

1

1

John Brown

1

2

3

 

Having consulted Google we think it may need to use the EARLIER function but we haven’t used that before so would appreciate some advice.

Thanks

  • iangilsenan's avatar
    iangilsenan
    6 years ago

    Thanks amitchandak.

    I managed to solve it without creating a Dates table and using the following measure:

     

    Cumulative Present =
    CALCULATE (
    COUNTAX ( FILTER ( ATTENDANCE,[Category] = "Present" ), [Category] ),
    FILTER (
    ALL ( ATTENDANCE[MarkDate] ),
    ATTENDANCE[MarkDate] <= MAX ( ATTENDANCE[MarkDate] )
    )
    )

3 Replies