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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ezFlow
Frequent Visitor

LOOKUPVALUE DAX with Many to Many relationship and multiple conditions

Hi,
I have 2 Tables, 
1. Roles 
2. Access

I want to create a colum in the Access table with the value of the 'Role_ID' field from the Roles table:
Where 'Dept Name' field in Roles = 'Department' field in Access, and RoleTitle in Roles = Title in the Access table.
There is a Many to Many relationship based on the Deptartmetns and Role Titles.

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ezFlow , You can take one value or concatenate values

new column

maxx(filter(Roles , Roles [Department] = Access [Dept Name] && Roles [RoleTitle ] = Access [Roles ]) ,Roles[Role_ID])

 

or

 

concatenatex(filter(Roles , Roles [Department] = Access [Dept Name] && Roles [RoleTitle ] = Access [Roles ]) ,Roles[Role_ID], ", ")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
WinterMist
Impactful Individual
Impactful Individual

@ezFlow -

 

All "X" functions iterate over a table (Parameter 1), evaluating an expression (Parameter 2) for each row in that table.

 

MAXX just takes the max value of all the evaluated expressions over all the rows.

 

--THIS CODE GETS ONLY 1 VALUE
new column =
maxx( --MAXX ITERATES TABLE P1, PERFORMING EXPRESSION P2
filter( --P1: FILTER RETURNS A FILTERED SUBSET OF ROLES TABLE
Roles,
Roles [Department] = Access [Dept Name]
&& Roles [RoleTitle ] = Access [Roles ]
),
Roles[Role_ID] --P2: EVALUATES EXP ROLE_ID FOR EACH ROW IN P1
)

 

 

https://docs.microsoft.com/en-us/dax/maxx-function-dax

 

Hope this is helpful to you.

Nathan

ezFlow
Frequent Visitor

Thank you Amit: That worked:

new column

maxx(filter(Roles , Roles [Department] = Access [Dept Name] && Roles [RoleTitle ] = Access [Roles ]) ,Roles[Role_ID])

Do you have any souce I can read on the MAXX command and how it works?

amitchandak
Super User
Super User

@ezFlow , You can take one value or concatenate values

new column

maxx(filter(Roles , Roles [Department] = Access [Dept Name] && Roles [RoleTitle ] = Access [Roles ]) ,Roles[Role_ID])

 

or

 

concatenatex(filter(Roles , Roles [Department] = Access [Dept Name] && Roles [RoleTitle ] = Access [Roles ]) ,Roles[Role_ID], ", ")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.