We’re glad that we were able to help you.
Well @JarrettM has already added his points on the use of USERELATIONSHIP and TREATAS function.
Now, I would also like to add one more point that simply distinguishes these two functions by miles.
You can use TREATAS function in place of USERELATIONSHIP function but you can’t use USERELATIONSHIP function in place of TREATAS function. Below is the reason provided for the reference -
If you’ve an inactive relationship between the tables one would by default think about USERELATIONSHIP function at the first place just because we’ve already created an active relationship and secondly most of the times when we witness this type of scenario that’s the first thing that comes to our mind. But it’s absolutely alright if you use the TREATAS function in this case. Then whether we create an active or inactive relationship at the first place it will simply doesn’t matter.
But TREATAS function is mostly applicable when you want to establish a relationship between the tables and it shows that it creates an “Many-to-Many” relationship. In this case, you’ll by default have to use the TREATAS function and USERELATIONSHIP cannot help in this case.
For example, if you’ve multiple dates in your model, you can use an USERELATIONSHIP function by creating inactive relationships between Fact Table and Date Table or you can simply use TREATAS function without creating any inactive relationships further. But let’s say you want to create an relationship where in your Products Tables contain multiple Product category name as well as multiple records for the Product category name in the Fact Table so now you’ll be forced to create a relationship virtually by using TREATAS function.
And that’s why I said above, TREATAS can be used in place of USERELATIONSHIP but USERELATIONSHIP cannot be used in place of TREATAS. So that’s why we can assume that TREATAS function has an upper hand in comparison to the USERELATIONSHIP function.
Hoping you find this distinction useful when it comes to TREATAS and USERELATIONSHIP function.
Thanks and Warm Regards,