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

View all the Fabric Data Days sessions on demand. View schedule

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
Microsoft Employee
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.

 

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
Microsoft Employee
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.

 

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors