Forum Discussion

Neustupa2001's avatar
Neustupa2001
Frequent Visitor
9 years ago

DAX - Graph budget changes over time

I'm struggling to graph budget amount changes over time.  The data that I have looks like:

 

ProjectID   |   ActivityID  |   Budget   |   StartDate   |   LastUpdateDate   |  IsCurrent

1                |   1               |  1,000       |   1/1/2017    |    1/1/2017             |  0

1                |   1               |  1,100       |   3/1/2017    |    3/1/2017             |  0

1                |   1               |  1,200       |   3/15/2017  |    3/25/2017           |  0

1                |   1               |  1,500       |   7/1/2017    |    7/1/2017             |  1

 

 

My data model does have a date table that I can use for this.  I've tried many different ways of doing this but none of them are returning the correct amount.  Essentially my logic needs to be - Budget = Budget where StartDate < Date && (LastUpdateDate>Date || IsCurrent = 1)

 

Thanks in advance for any help you can provide.

4 Replies

  • Neustupa2001's avatar
    Neustupa2001
    Frequent Visitor

    I've gotten closer with

     

    testing = CALCULATE(
      SUM(FactBudgetHistory[BudgetCost]),
        LASTNONBLANK(view_DimDate[Date],
          CALCULATE(SUM(FactBudgetHistory[BudgetCost]))

      )
    )

     

    This is giving me the correct value if I'm just looking at one project and activity at a time but, it is not totaling up correctly.

    ProjectID | ActivityID | Budget | StartDate   | LastUpdateDate | IsCurrent
    1              | 1              | 1,000    | 1/1/2017   | 1/1/2017           | 1
    1              | 2              | 800       | 1/12/2017 | 1/12/2017        | 1

     

    The above data example would give me a total of 800 for January but I need it to be 1,800 because these are different activities.

    • v-jiascu-msft's avatar
      v-jiascu-msft
      Microsoft Employee

      Hi Neustupa2001,

       

      Maybe you could try this formula:

      New =
      CALCULATE (
          SUM ( FactBudgetHistory[Budgetcost] ),
          FILTER (
              ALLEXCEPT ( 'FactBudgetHistory', FactBudgetHistory[ProjectID] ),
              'FactBudgetHistory'[IsCurrent] = 1
          )
      )

      Could you please tell me what the [date] is?

      Budget = Budget where StartDate < Date && (LastUpdateDate>Date || IsCurrent = 1)

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      Best Regards!

      Dale

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Neustupa2001,

     

    Could you please tell me if your problem was resolved? Could you please share the answer or mark the proper answer as solution if it's convenient for you? That will be a help to the others.

    Best Regards!
    Dale

    • Neustupa2001's avatar
      Neustupa2001
      Frequent Visitor

      I'm sorry for taking so long to get back to this.  We have been trying to solve this with our data model by putting a daily value in there but I don't think that I going to be sustainable due to hundreds of thousands of records a day being inserted.

       

      I believe I'm overcomplicating what I'm trying to accomplish here.  The above is a dumbed down version of what I'm trying to do.  Instead what I'm getting is