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.

 

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors