Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Analitika
Post Prodigy
Post Prodigy

Use relationship with filters

Have to use filter on userelationship?

 

 

Measure 2 =

CALCULATE(
sum('Table1'[DebtSumNacCurrency]),
'Table1'[OPERACNO]='Table2'[SkOperacNo],
USERELATIONSHIP('Table2'[SkOperacNo],'Table1'[OPERACNO])
)
 
got error on ='Table2'[SkOperacNo]  - The expression contains multiple columns
trying to add max('Table2'[SkOperacNo]) but error - A function Max has been used in a True/False expression
 
 
 
15 REPLIES 15
amitchandak
Super User
Super User

@Analitika , You do nor need them when you use use reltion

CALCULATE(
sum('Table1'[DebtSumNacCurrency]),
USERELATIONSHIP('Table2'[SkOperacNo],'Table1'[OPERACNO])
)

 

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

It duplicates values wrong

 

2020-08-11_113344.png

but must return only one value where SkOperacNo = 64477 

tex628
Community Champion
Community Champion

You need to remove OPERACNO from the table. The relationship is only active in the measure calculation, you cant display both columns in the table as the relationship will be inactive there. 

/ J


Connect on LinkedIn

I tryed, not make any sence, result is same

tex628
Community Champion
Community Champion

You cant have any columns from table1. Remove all columns from table 1, if there's still duplicates of 64477 after that the issue is related to something else. 


Connect on LinkedIn

But i need to have them

tex628
Community Champion
Community Champion

The USERELATIONSHIP() only works within the specific measure. For all the other columns there is no relationship between table 1 and table 2 which is why you can not combine columns from the 2 different tables! 

If you can provide an image of all the data you need displayed in your table I can help you accomplish this, but untill then it's very hard to help. 

/ J


Connect on LinkedIn

I want get everything from Table2 and only one value from 'Table1'[DebtSumNacCurrency]

@Analitika
You are creating a MEASURE, so the measure does not have the row context of Table2. Only when you put the measure in a visual will it calculated according to what is in the table visual or matrix or column chart.

Could you please share a screenshot of your Model view so we can see the relationships. From the screenshot you have shared already, it looks like the measure is not using the relationship properly. Does 64477 exist in both tables as Table2'[SkOperacNo] and Table1'[OPERACNO] ?

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

PBIX 

DOKMNR must be only from Table1

ApNr must be  from Table2 where OPERACNO = DengOperacNo

 

 

 

 

@Analitika  You should share a sample file now, also which one of the two tables is on the many side?

 

Measure 2 =
CALCULATE (
    SUM ( 'Table1'[DebtSumNacCurrency] ),
    ALLEXCEPT ( 'Table1', 'Table2'[SkOperacNo] ),
    USERELATIONSHIP ( 'Table2'[SkOperacNo], 'Table1'[OPERACNO] )
)

 

Table2 on many side, your example is not work as i cant set 

ALLEXCEPT ( 'Table1',) 'Table2'[SkOperacNo]  

@Analitika , saw your update.

Can you share sample data and sample output in table format?

tex628
Community Champion
Community Champion

You should be able to remove the filterstatement from the measure :

Measure 2 = 
CALCULATE(
sum('Table1'[DebtSumNacCurrency]),
USERELATIONSHIP('Table2'[SkOperacNo],'Table1'[OPERACNO])
)


It has the same function as the userelationship. 

I can't really see anything about this measure that would cause an error. Are you trying to add something to the measure? Can you post the exact error message? 

/ J

/ r


Connect on LinkedIn

It give me a wrong total, it sums all table sums but not needed

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.