Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sa1
Frequent Visitor

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.

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
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.

 

6.PNG

 

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

 

2.PNG

 

Regards,

View solution in original post

4 REPLIES 4
v-sihou-msft
Employee
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.

 

6.PNG

 

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

 

2.PNG

 

Regards,

GilbertQ
Super User
Super User

Hi @sa1

 

In order for the DateAdd to work you need to have a Date table.

 

You can create one using my blog post here: https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fi...

 

Then you can relate your table to this Date Table.

 

Once you have done that you can then use the DATEADD function using the above created Date table.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

sa1
Frequent Visitor

Hi,

I already have  a table with only Disntict Date Values

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.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.