cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
padmajadrao
Frequent Visitor

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 @padmajadrao ,

 

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.

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 @padmajadrao ,

 

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
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.