Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Count Jobs by Status Over Time

I have data similar to the below:

IDCreatedConvertedCancelled
11/1/2020  
21/1/20201/15/2020 
31/1/20201/15/20202/15/2020
41/1/2020 1/15/2020

Jobs can have the following statuses: Opportunity / Order / Work Not Done. I need to count the number of jobs by status over time, being able to filter by the [Created] date.

 

An example of some questions may be "How many opportunities did we have on January 5th?" or "How many orders did we have in January 2020?"

 

The logic should compare the above dates to the timeline [date], applying the following logic:

Opportunity If [Converted] = NULL then "Opportunity"
Work Not DoneIf [Converted] <> NULL and [Cancelled] <> NULL then "Work Not Done"
OrderIf [Converted] <> NULL and [Cancelled] = NULL then "Complete"

 

For example...

  • Record 1 is an "Opportunity" from 1/1 onward
  • Record 2 is an "Opportunity" from 1/1 to 1/14 and "Order" from 1/15 onward
  • Record 3 is an "Opportunity" from 1/1 to 1/14, an "Order" from 1/15 to 2/14, and "Work Not Done" from 2/15 onward
  • Record 4 is an "Opportunity" from 1/1 onward (a cancelled date doesn't mean a conversion can't happen later)

 

Thanks for any help!

  • Anonymous's avatar
    Anonymous
    6 years ago

    amitchandak -- I appreciate all of your help! Below is the solution I ended up implementing...

     

    I'm using the following formulas to count opportunities. The first counts jobs if they where created in that peorid, while the second does a cumulative count. This helps show a month to month as well as an overview:

    Opportunity = 
    	CALCULATE(
    		COUNT('Data'[ID])
    		,FILTER(
    			'Data'
                , 'Data'[Created] <= MAX('Date'[Date])
                    && ( ISBLANK('Data'[Converted] )
    				|| 'Data'[Converted] > MAX('Date'[Date]) )
    	    )
            ,CROSSFILTER(
                'Data'[Created]
                ,'Date'[Date]
                ,None
            )
        )

     

    Opportunity (Cumulative) = 
        CALCULATE(
            COUNTX(
                FILTER(
                    'Data'
                    ,'Data'[Created] <= MAX('Date'[Date])
    					&& ( ISBLANK('Data'[Converted])
                        || 'Data'[Converted] > MAX('Date'[Date]) )
                )
                ,'Data'[ID]
            )
            ,CROSSFILTER(
                'Data'[Created]
                ,'Date'[Date]
                ,None
    		)
    	)

     

    I also applied a relationship between 'Date'[Date] and 'Data'[Created] to allow proper filtering.

     

    Thanks again!

5 Replies