Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DateAdd numbers interval based on column

Hi,

 

I have an issue I can't seem to find my way in.

I'm trying to have a variable interval number in DATEADD

My data is along the following lines:

 

Invoice:
DispatchDate | Conditiondays | Amount | etc...

 

DateTable

Date | etc...

Currently I have a calculated measure:

SumAmount = CALCULATE ( SUM ( Amount ), USERELATIONSHIP ( DateTable[Date], Invoice[DispatchDate] ) )

In the next measure I want to do the following but this does not work:
CALCULATE ([SumAmount], DATEADD ( DateTable[Date], Conditiondays, Day ) )

 

Is it possible to get this to work?

5 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Greg, I'll dive into your dateadd part in a bit and see if it helps me out!

  • Anonymous , in the measure you can have like

    CALCULATE ([SumAmount], DATEADD ( DateTable[Date], max(Invoice[Conditiondays]), Day ) )

     

    What are you trying to achieve here ?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak ,

      Thanks but this does not work as intended.

       

      I have multiple dates in the invoice table. Like pay date, creation date and dispatchdate.

      I want to forecast based on the dispatchdate + condition days after how many days you can expect x amount.
      Below the outcome. Your option was used in the last column.

      30 manual is CALCULATE ([SumAmount], DATEADD ( DateTable[Date], 30, Day ) ), which should be the eventual outcome.

       

      Edit: Actually my first measure also does not seem to work properly

      The top date should be 30 days after the bottom date, which somehow is -30 days.. After putting a - before it in the formula it was fixed.

       

       

       

  • v-robertq-msft's avatar
    v-robertq-msft
    Community Support

    Hi, Anonymous 

    Has the documents that Greg posted helped you to found a solution?

    If so, would you like to mark his reply as a solution so that others can learn from it too?

    If not, you can post some sample data so that we can help you in advance.

     

    Thanks in advance!

    How to Get Your Question Answered Quickly 

     

    Best Regards,

    Community Support Team _Robert Qin

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