Power BI - Calculating an S curve with a calendar and a tasks table

72 views Asked by At

I'm trying to automate some reports here at my company with power BI, but I'm having trouble with the calculation of our projects S curve. We use MS project to plan our activities, and I can export the data to an access file, with start date, end date, task values, planned start date, planned end date...

I have also created a calendar table and made the following column:

Sum of the value of all completed tasks by date in my calendar table

The problem is that the value of each task is only accounted after it is completed, so tasks that have started but are uncompleted don't contribute, making the graph have steps:

Part of the graph

I want to make this curve smoother by calculating the value added by the unfinished tasks, multiplying the task value and the difference between the start date and the calendar date and then dividing this by the difference between the start date and the end date of the task.

I have tried many different functions, but nothing has worked so far. I am working at the calendar table, and currently the column expression Looks like this:

Parciais = CALCULATE( 
    SUMX(

        MSP_EpmTask_OlapView, MSP_EpmTask_OlapView[Valor Planejado] * (DATEDIFF(RELATED('Calendar'[Data]), MSP_EpmTask_OlapView[Término],DAY) +1) / (DATEDIFF(MSP_EpmTask_OlapView[Início], MSP_EpmTask_OlapView[Término],DAY)+1) 

        ), 
    MSP_EpmTask_OlapView[É Resumo]=FALSE(),
    FILTER (

        MSP_EpmTask_OlapView,
        MSP_EpmTask_OlapView[Término] > 'Calendar'[Data]

        ),

    FILTER (

        MSP_EpmTask_OlapView,
        MSP_EpmTask_OlapView[Início Agendado] < 'Calendar'[Data]

        )
    )

I know the Related function is not what I am supposed to use here, but I have tried many other solutions and this one at least does not return an error (it is returning 0 to the first datediff). The tables are the following:

Tables used

Can someone please help me?

1

There are 1 answers

0
Sam Nseir On

Didn't quite understand the question/ask - however see if this cleaned-up DAX helps solve it:

Parciais = 
  SUMX(
    FILTER(
      MSP_EpmTask_OlapView,
      [É Resumo] = FALSE() &&
      [Término] > 'Calendar'[Data] &&
      [Início Agendado] < 'Calendar'[Data]
    ),
    (
      var d1 = DATEDIFF(MIN('Calendar'[Data]), MSP_EpmTask_OlapView[Término], DAY) +1
      var d2 = DATEDIFF([Início], [Término], DAY) + 1
      return DIVIDE( [Valor Planejado] * d1, d2)
    )
  )