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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

DAX to retrieve value from another column based on a condition

Hi Community,

 

I need help in writing a DAX for retrieving a value from another coumn based on a condition.

 

For example in the following dataset, for P_id =3, I want to compare the corresponding addres_id (567) with any existing address ids, if a match is found populate address column with its corresponding address(in this case populate 'FGH')

 

Capture.JPG

Many thanks in advance,

Meena

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

try this code for a calculated column:

 

Column =
VAR _address_id = 'Table'[Address_id]
RETURN CALCULATE(DISTINCT('Table'[Address]), FILTER('Table', 'Table'[Address_id] = _address_id && 'Table'[Address] <> BLANK()))

 

OR

 

Column =
VAR _address_id = 'Table'[Address_id]
RETURN CALCULATE(MAX('Table'[Address]), FILTER('Table', 'Table'[Address_id] = _address_id))
 
 


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

1 REPLY 1
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

try this code for a calculated column:

 

Column =
VAR _address_id = 'Table'[Address_id]
RETURN CALCULATE(DISTINCT('Table'[Address]), FILTER('Table', 'Table'[Address_id] = _address_id && 'Table'[Address] <> BLANK()))

 

OR

 

Column =
VAR _address_id = 'Table'[Address_id]
RETURN CALCULATE(MAX('Table'[Address]), FILTER('Table', 'Table'[Address_id] = _address_id))
 
 


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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.

Top Solution Authors