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
ak77
Post Patron
Post Patron

Table Join conditional(multiple columns)

Hi all,

Need a help on the below scenario . please check and help if possible

ak77_1-1720220486541.png

 

i have Table 1 and Table 2 to be joined based on 2 fixed columns( sequence and code) and 1 conditional column.

shortname/nodename(Table1) can have values from shortname or nodename from table2.  so the condition to check needs to be done.

 

Final result is value to be made available in Table2. 

 

sample pbix is avaialble in the below link with data if anyone wants to try.

 

https://drive.google.com/file/d/16YFu-BEKLHR4tnmhrLbodjJf7EOJvk9u/view?usp=sharing

 

2 ACCEPTED SOLUTIONS

Hi,

This calculated column formula works

Column = coalesce(CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[shortname]))),CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[nodename]))))

Hope this helps.

Ashish_Mathur_0-1720395514693.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

v-heq-msft
Community Support
Community Support

Hi @ak77 ,
Thanks for @Ashish_Mathur  reply.

Based on the data you provide, you can first create relationships based on the sequence you want to pass, and then create a calculated column in Table 2

vheqmsft_0-1720678351175.png

Value = 
IF(
    'Table 2'[shortname] = RELATED('Table 1'[shortname/nodename]) || 'Table 2'[nodename] = RELATED('Table 1'[shortname/nodename]),
    RELATED('Table 1'[value])
)

Final output

vheqmsft_1-1720678384518.png

 

Best regards,
Albert He

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

7 REPLIES 7
v-heq-msft
Community Support
Community Support

Hi @ak77 ,
Thanks for @Ashish_Mathur  reply.

Based on the data you provide, you can first create relationships based on the sequence you want to pass, and then create a calculated column in Table 2

vheqmsft_0-1720678351175.png

Value = 
IF(
    'Table 2'[shortname] = RELATED('Table 1'[shortname/nodename]) || 'Table 2'[nodename] = RELATED('Table 1'[shortname/nodename]),
    RELATED('Table 1'[value])
)

Final output

vheqmsft_1-1720678384518.png

 

Best regards,
Albert He

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

 

Thanks @v-heq-msft  and @Ashish_Mathur , The solution u both provided helped in resolving the issue while using import and direct mode 

 

Thanks again. 

ak77
Post Patron
Post Patron

@Ashish_Mathur , thanks for reply.

 

This works perfectly when import mode of data is used. but unfortunately i am using direct mode(huge amout of data led us to this decision) and this DAX is failing . 

 

is there a way to achieve this using direct query. Please let me know

Sorry i would not know.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ak77
Post Patron
Post Patron

@Ashish_Mathur , The value column of Table2 should have 2 and 3 from Table1 

 

My apologies for wrong values in description.. please let me know if it is possible 

 

ak77_0-1720382282779.png

 

Hi,

This calculated column formula works

Column = coalesce(CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[shortname]))),CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[nodename]))))

Hope this helps.

Ashish_Mathur_0-1720395514693.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Column = IFERROR(CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[shortname]))),CALCULATE(SUM(Table1[value]),FILTER(Table1,Table1[sequence]=EARLIER(Table2[sequence])&&Table1[code]=EARLIER(Table2[code])&&Table1[shortname/nodename]=EARLIER(Table2[nodename]))))

Hope this helps.

Ashish_Mathur_0-1720236013590.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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