Forum Discussion
2 date ranges for data
Hi,
You can get much better performance if you actually create the two relationships as inactive ones, and then you enable them on demand in the measure, using a slight variation of your code. This is the model:
And, with the model in place, you author the measures in this way:
Sales_CALENDAR =
CALCULATE (
[Total_Sales],
USERELATIONSHIP( 'Calendar'[Date], Sales[Date] )
)
Sales_CALENDAR_SEC =
CALCULATE (
[Total_Sales],
USERELATIONSHIP( Calendar_Sec[Date], Sales[Date] )
)By leveraging relationships, you obtain much better performance, since you are using Storage Engine instead of Formula Engine. You need a few hundre millions rows to notice the difference, yet is is worth optimizing the model from the beginning. Besides, the code is a bit cleaner.
I wish I knew how to attach a PBIX here, but I am just learning how to answer, attaching a file looks too hard for me :)
Have fun with DAX!
Alberto Ferrari
http://www.sqlbi.com
Hey AlbertoFerrari
you can't attach files, just embed screenshots, if you want to share a file you have to share a link that directs to the file.
Regards
- AlbertoFerrari9 years agoMost Valuable Professional
Ouch... such a pity! 90% of the answers would be so much easier if we could share PBIX files here... anyway, thanks for confirming I am not too old not to see where the "share a file" button was hidden, I was searching for it everywhere!
- MFelix9 years agoSuper User
Hi AlbertoFerrari,
What I usually do is to add a Wetranfers link but there are other persons that do it on the dropbox/google drive.
On an additional note the add file option is available when you make an issue post or a data story (is also treated as an issue).
Regards,
MFelix