Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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 SeverityNew Week
42632 Minor1/15/2017
42633 Major1/15/2017
42634 Major1/15/2017
42669 Major1/15/2017
42670 Major1/15/2017
42746 Minor1/22/2017
42748 Minor1/22/2017
42772 Major1/22/2017

 

I want to have an intermediate table like:

 

Week start dateUrgent New Count
1/15/20170
1/22/20170
1/29/20171
2/5/20171
2/12/20176
2/19/20176

 

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. 

 

Thanks in advance.

  • 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

  • Icey's avatar
    Icey
    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's avatar
      Anonymous
      Not applicable

      This is great. Thank you so much!