Forum Discussion

sa1's avatar
sa1
Frequent Visitor
9 years ago
Solved

DATEADD not working

Hi,

I have been trying to use the DATEADD function to compute a certain attribute "cost" for the  previous Month.

I'm using a horizontal bar graph. The Date Attribute for the table containing cost is not contigous - Table 1 . However I have created a set of disntict dates in another table - Table 2. I have related the two tables as a many to one relation. I use the Date column from table two as  a argument to Dateadd. However my the aggregation of the previous cost is wrong.

  • sa1

     

    As you said, you fact table has many to one relationship to your date dimension table. Since you have multiple entries for same date in fact table, you need to use ALLEXCEPT() function to group the calculation.

     

     

    And make sure you include the date field from date dimension into visual.

     

     

    Regards,

4 Replies

    • sa1's avatar
      sa1
      Frequent Visitor

      Hi,

      I already have  a table with only Disntict Date Values

      • GilbertQ's avatar
        GilbertQ
        Super User
        Hi there are the dates contiguous? In that there is date for every day even if you have no data?

        If you do not have the contiguous then it will not recognize it as a Date table and the DateAdd function will not work.
  • v-sihou-msft's avatar
    v-sihou-msft
    Microsoft Employee

    sa1

     

    As you said, you fact table has many to one relationship to your date dimension table. Since you have multiple entries for same date in fact table, you need to use ALLEXCEPT() function to group the calculation.

     

     

    And make sure you include the date field from date dimension into visual.

     

     

    Regards,