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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
cferv_77
Helper I
Helper I

Using IF function to reference a related table

Hello,

 

I am trying to create a DAX calculated column based on a column from a different table that has a relationship with the main table. I am experiencing some errors when trying to merge several tables with a SharePoint table. Is there a way to create a calculated column based on the relationship?

 

The two tables have relationship on ID and trying to create a calculated column on Table A based on a date column on Table B using IF function.

 

So is it possible to use IF function to reference a related table?

Left side is table1 and right side is table2. 

 

IDDate1  Calc Col  IDDate2
11/1/2022  IF(Date1==Date2, 1, 0)  11/1/2022
23/1/2022  IF(Date1==Date2, 1, 0)  23/1/2022
34/2/2022  IF(Date1==Date2, 1, 0)  34/2/2022

 

1 ACCEPTED SOLUTION
serpiva64
Solution Sage
Solution Sage

Hi,

if i understood your problem you can try this calculated column

Column = var CurrId = 'Table'[ID]
var result = if('Table'[Date1 ]= Related('Table (2)'[Date2]),1,0)
return
result

serpiva64_0-1665497920801.png

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

View solution in original post

2 REPLIES 2
dcrosseto
Resolver II
Resolver II

Hi @cferv_77

 

If you're having troubles with the relationships, you can disable it and try to apply manually using USERELATIONSHIP.

 

https://prnt.sc/LZ8qTEt2TW4n

 

And then create a measure like this, you can also apply some conditional like you mentioned. 

 

Measure = 

CALCULATE(
    SUM(Table1[Value]),
    USERELATIONSHIP(Table1[Id],Table2[ID])
)

 

Hope it was helpful.

 

Regards,

Douglas.

serpiva64
Solution Sage
Solution Sage

Hi,

if i understood your problem you can try this calculated column

Column = var CurrId = 'Table'[ID]
var result = if('Table'[Date1 ]= Related('Table (2)'[Date2]),1,0)
return
result

serpiva64_0-1665497920801.png

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.