cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Anonymous
Not applicable

## Cumulative Counts based on two date values

Hello everyone,

I am working on a project to convert a manual excel report into a Power Bi dashbaord to create a line chart for three categories on items ( Urgent/ Minor/Major).

The raw data look like this:

 Work Item Id Severity New Week 42632 Minor 1/15/2017 42633 Major 1/15/2017 42634 Major 1/15/2017 42669 Major 1/15/2017 42670 Major 1/15/2017 42746 Minor 1/22/2017 42748 Minor 1/22/2017 42772 Major 1/22/2017

I want to have an intermediate table like:

 Week start date Urgent New Count 1/15/2017 0 1/22/2017 0 1/29/2017 1 2/5/2017 1 2/12/2017 6 2/19/2017 6

Here, 'Urgent New Count' ( similarly, 'Minor' and 'Major' item counts should be calculated) is calculated such that : If the Work Item is 'Urgent' and the 'New Week' column in the firsttable is less than the date mentioned in the second table, count it. The column ('Week start date') refers to the first date of every week ( Sunday is the first day of the week). This column's value will keep increasing every week as new dates get added to both the tables.

In excel, to calculate the 'Urgent New Count': COUNTIFS(Severity,"=*Urgent*",NewWeek, CONCATENATE("<",\$B5))

was used. Here, the 'Severity' criteria referred to the first 'Severity' column of first table and the the second argument does the comparision.

This would create a running count of work items where the current count may/may not be higher that the previous cell's count if there are any new items

Any help is really appreciated.

1 ACCEPTED SOLUTION
Community Support

Hi @Anonymous ,

Please pay attentation to ' '(Space) in your data. This is my PBIX file.

You can create your columns like this:

```Urgent New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Urgent"
)
)```
```Major New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Major"
)
)```
```Minor New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Minor"
)
)```

Best Regards,

Icey

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

2 REPLIES 2
Community Support

Hi @Anonymous ,

Please pay attentation to ' '(Space) in your data. This is my PBIX file.

You can create your columns like this:

```Urgent New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Urgent"
)
)```
```Major New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Major"
)
)```
```Minor New Count =
CALCULATE (
COUNTROWS ( 'Table 1' ) + 0,
FILTER (
'Table 1',
'Table 1'[New Week] < EARLIER ( 'Table 2'[Date] )
&& ( 'Table 1'[Severity] ) = "Minor"
)
)```

Best Regards,

Icey

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

Anonymous
Not applicable

This is great. Thank you so much!

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors