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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Chris2016
Resolver I
Resolver I

Create measure or column that specifies conditions from two related tables

Hi,

 

I need some help with the following issue:

I have two tables which are related by Name (many to one, single cross filter direction):

 

Users:

NameCountry
JohnUSA
MarkCanada
LilyFrance
JennyCanada
JuneUSA
MarieFrance

 

Activities:

NameID
John123
John456
June123
Jenny123
Jenny456
Marie123


I need to create a measure or a column in the Users table that specifies the following ineligibility condition: The Name must be from Country "Canada", and the ID must be "123". in the above example, the result (or flag) would be Jenny. Creating the Country ineligibility output is done, but the ID output from the users table is not recognized. Any ideas on how that can be done?

 

Many thanks!

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Chris2016 

 

You can try the following methods.
Measure:

Measure = 
Var _N1=CALCULATE(MAX(Users[Country]),FILTER(ALL(Users),[Name]=SELECTEDVALUE(Activities[Name])))
Return
IF(_N1="Canada"&&SELECTEDVALUE(Activities[ID])=123,SELECTEDVALUE(Activities[Name]),"Null")

vzhangti_1-1668134605700.png

Column:

Column = 
Var _N1=CALCULATE(MAX(Users[Country]),FILTER(ALL(Users),[Name]=EARLIER(Activities[Name])))
Return
IF(_N1="Canada"&&[ID]=123,[Name],BLANK())

vzhangti_2-1668134631365.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

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

5 REPLIES 5
wdx223_Daniel
Super User
Super User

the users table must be unique,then

CalculatedColumn=IF(Activities[ID]="123"&&RELATED(Users[Country])="Canada",Activities[Name])

 

and for DAX, Users[Name] is in the rows,

Measure=IF(MAX(Users[Country])="Canada",MAXX(FILTER(Activities,Activities[ID]="123"),Activities[Name]))

v-zhangti
Community Support
Community Support

Hi, @Chris2016 

 

You can try the following methods.
Measure:

Measure = 
Var _N1=CALCULATE(MAX(Users[Country]),FILTER(ALL(Users),[Name]=SELECTEDVALUE(Activities[Name])))
Return
IF(_N1="Canada"&&SELECTEDVALUE(Activities[ID])=123,SELECTEDVALUE(Activities[Name]),"Null")

vzhangti_1-1668134605700.png

Column:

Column = 
Var _N1=CALCULATE(MAX(Users[Country]),FILTER(ALL(Users),[Name]=EARLIER(Activities[Name])))
Return
IF(_N1="Canada"&&[ID]=123,[Name],BLANK())

vzhangti_2-1668134631365.png

Is this the result you expect?

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Chris2016
Resolver I
Resolver I

Hi, John,

 

I cannot add a column in the Activities table, because that is not where I need it, as only a few of the users are present in that table and the new column must account for every user in the Users table.

I already tried using RELATED with a new column in the Users table, but the "ID" column from Activities is not recognised (the error is that it either does not exist, or there is no relationship between the tables - although that is not true). 
Thanks!

 

RELATED only works from the many side to the one side of a relationship, to go the other way you need RELATEDTABLE.

Try this as a column on Users.

Eligible = 'Users'[Country] = "Canada" && NOT ISEMPTY( FILTER( RELATEDTABLE( 'Activities'), 'Activities'[ID] = 123))

 

johnt75
Super User
Super User

You could create a column on the Activities table like

Eligibile = 'Activities'[ID] = 123 && RELATED('Users'[Country]) = "Canada"

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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