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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dirkkoch
Helper III
Helper III

Userelationship with if function

Hi,

 

I have two tables A & B with a many to one relationship.  This relationship cannot be activated due to activation with another table C.

 

What I want to do is to create the new column marked in yellow by activating the relationship and comparing value from Table A with value from Table B. If equal, then write Date from Table B in New Column in Table A. I am looking for your support. Thank you in advance!

dirkkoch_0-1644319768151.png

 

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @dirkkoch ,

 

You could try lookupvalue() function.

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

column = lookupvalue('tableB'[date],'tableB'[value],'tableA'[value])

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

Hi @dirkkoch ,

 

You could try lookupvalue() function.

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

column = lookupvalue('tableB'[date],'tableB'[value],'tableA'[value])

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Samarth_18
Community Champion
Community Champion

Hi @dirkkoch ,

 

Create a column with this code:-

Column =
CALCULATE (
    MAX ( 'Table B'[Date] ),
    FILTER ( 'Table B', 'Table B'[Value] = 'Table A'[Value] ),
    USERELATIONSHIP ( 'Table A'[Value], 'Table B'[Value] )
)

Output:-

image.png

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

@Samarth_18 thank you, we are getting closer to a solution. Most of the dates are returned correctly, but still some blanks are left, although the values appear in both tables and a date would be expected. But the rest of the dates are correct.

@dirkkoch Is it possible for you to share PBIX file after removing sesitive data?

In the mean time you can try below code:-

Column =
CALCULATE (
    MAX ( 'Table B'[Date] ),
    FILTER ( 'Table B', TRIM ( 'Table B'[Value] ) = TRIM ( 'Table A'[Value] ) ),
    USERELATIONSHIP ( 'Table A'[Value], 'Table B'[Value] )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

dirkkoch
Helper III
Helper III

@Greg_Deckler Unfortunately then it only writes back the latest date but not the exact date listed in table B.

Greg_Deckler
Super User
Super User

@dirkkoch Maybe CALCULATE(MAX('Table B'[Date]),USERELATIONSHIP('Table A'[Value],'Table B'[Value]))



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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