Forum Discussion
Inactiv Relationship in Calculated column
- 5 years ago
Olenard , In the case of a column related, will not work with inactive relation, and use relation might not work well.
You can use lookupvalue or can use a formula like this
City Name = maxx(FILTER(geography,geography[City Id]=Sales[City Id]),geography[City])
refer to this video : https://www.youtube.com/watch?v=czNHt7UXIe8
- 5 years ago
Anonymous
Of course you can change the active relationship when doing calculations in a table. For instance, if you have a simple model like:
with the relationship inactive, you can create the calculated column:
Res = CALCULATE(SUM(Table1[Col1]), USERELATIONSHIP(DimT[Col1],Table1[Col1]))on table DimT, which will work fine using the otherwise inactive relationship.
It is true that it won't work with RELATED( ) as I suggested earlier but that has nothing to do with USERELATIONSHIP( ) but rather with CALCULATE( ). RELATED( ) requires a row context and that will be lost through context transition when using CALCULATE( ). A calc column in Table1 such as:
New col = CALCULATE( RELATED(DimT[Col2]) )with the an active relationship will not work either, precisely for that reason, while this would:
New col = RELATED( DimT[Col2] )Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Anonymous
Of course you can change the active relationship when doing calculations in a table. For instance, if you have a simple model like:
with the relationship inactive, you can create the calculated column:
Res = CALCULATE(SUM(Table1[Col1]), USERELATIONSHIP(DimT[Col1],Table1[Col1]))
on table DimT, which will work fine using the otherwise inactive relationship.
It is true that it won't work with RELATED( ) as I suggested earlier but that has nothing to do with USERELATIONSHIP( ) but rather with CALCULATE( ). RELATED( ) requires a row context and that will be lost through context transition when using CALCULATE( ). A calc column in Table1 such as:
New col = CALCULATE( RELATED(DimT[Col2]) )
with the an active relationship will not work either, precisely for that reason, while this would:
New col = RELATED( DimT[Col2] )
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- Anonymous5 years agoNot applicable
"Of course you can change the active relationship when doing calculations in a table". Of course, you can't, AlB. We're talking here about RELATED in fact and USERELATIONSHIP can't change the connection in a table (calculated column) in a way that RELATED work how one would expect it; hence you have to use LOOKUPVALUE. There's an article about it on www.sqlbi.com and in their book as well , as I mentioned. Here's something you SHOULD read: https://www.sqlbi.com/articles/userelationship-in-calculated-columns/