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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Relationship not getting created in a date table

Hi,

 

I have a table with the latest sales for today.  Now, i want to go back and fetch the sales for 1 month back, 2 months back likewise upto 6 months back.  However, the previous data is available in a different fact table.  I have a separte date dimension table which is connected to both the fact table.  When i am going one - six months back, since the date has to be customized based on the availability of the sales, i am using the function  as follows : 

VAR dateincurrenttable =
Max (Currentday_latest[Last Updated])
VAR date1monthbefore_0 =
DATE ( YEAR ( dateincurrenttable ), MONTH ( dateincurrenttable ) - 1, DAY ( dateincurrenttable ) ) 
RETURN
date1monthbefore_0
However, when i pull the date from the date dimension table, i am getting an error message saying :
An Argument of Function Date has wrong data type or result is too small or too large
 
But the date1monthbefore_0 is coming in the date format and also the result is correct.
 
I even tried using treatas function for the date table and the currentday_latest table.  However, nothing seems to work.  
 
Any help.
 
Thanks
Padmaja 



 
return 
1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

In other words, you want to get the sales data of the previous month, but the sales data of the previous month are in another fact table, so you need to create a date column, right?

Maybe you can use the "Append Queries" feature to merge the two fact tables.

v-lionel-msft_0-1620191699146.png

 

Best regards,
Lionel Chen

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

 

View solution in original post

3 REPLIES 3
daxer-almighty
Solution Sage
Solution Sage

If MONTH( dateincurrenttable ) is 1, then MONTH( dateincurrenttable ) - 1 = 0 and this is not allowed in DATE. Also, months do not have the same number of days, so if you happen to have a month with 31 days and the previous only had 30... then the DATE can't be created. There are many other issues with your approach (but I don't have time to explain them right now) so I'd kindly suggest you should abandon this way of coding. Please look for something more robust: time-intel functions.

Anonymous
Not applicable

Thanks Daxer.  Yes, i understand the issues. and i worked out on multiple options but without any solutoin except that i get the result but i need to create different measures and just show the data in the card format.   i was trying to show the data as bar graph with dates as axis.

 

Tahnks 

Hi @Anonymous ,

 

In other words, you want to get the sales data of the previous month, but the sales data of the previous month are in another fact table, so you need to create a date column, right?

Maybe you can use the "Append Queries" feature to merge the two fact tables.

v-lionel-msft_0-1620191699146.png

 

Best regards,
Lionel Chen

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

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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