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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MarcUrdang
Post Patron
Post Patron

Related function

Hello

I am trying to write a calculation where I compare various data and then if true return a result. One of these fields comes from another table and when I use the Related function it returns an error saying that either the filed doesn't exist or there is no relationship bestween the tables (which there is).

 

Any guidance would be appreciated.

 

The calc is as follows:

 

Client Order Number =
IF([Charge Code/ GL] = "DRB","Drawback",
             IF('Chg Code Master'[Charge Code/ GL] <> "DRB" && RELATED('Invoice Line'[ClientLineOrderNo]<>BLANK(),                                               RELATED('Invoice Line'[ClientLineOrderNo],"PO Needed"))))
1 ACCEPTED SOLUTION
vivran22
Community Champion
Community Champion

Hello @MarcUrdang 

 

Can you share the sample pbix file or snapshot of the model view?

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

View solution in original post

9 REPLIES 9
v-frfei-msft
Community Support
Community Support

Hi @MarcUrdang ,

 

Kindly share your sample data and excepted result to me, You can just copy and paste your content here directly. 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
amitchandak
Super User
Super User

@MarcUrdang 

First, both tables should be related. Second I see two related. I think you have to use it only on one side. Side from where you are trying to get data.

There is detailed explanation on https://databear.com/dax-related-table-functions/

Hi Amit .. yes they are both related .. and the tables are many to many relationship .. so I guess then i cannot do this?

@MarcUrdang , need sample to test. I think in your formula, you used related on both sides. try using only on one side.

 

Some time I also do this

Get from Table 2 in table 1

New Column = maxx(filter(table2,table2[Col1]= table1[col1] && table2[Col2]= table1[col2] ),table2[required_col])

Hi Vivek .. thx so much .. it is very close but not quite correct as now it brings back just one of the PO Numbers against every line nad not the actual PO number for that line .. can I mail you the workbook? You will then see what I mean. Or perhaps I can show you in Teams? I can set up a call?

thanks
Marc

Sorry Amit .. I put the wrong name in 😞 

@ImkeF , @Greg_Deckler , Can you help.

 

These tables have many to many join on the job no. And one on the table has line no. In visual he wants to bring line no from another table.

vivran22
Community Champion
Community Champion

Hello @MarcUrdang 

 

Can you share the sample pbix file or snapshot of the model view?

 

Cheers!
Vivek

https://www.vivran.in/
Connect on LinkedIn

Hi Vivek .. thank you so much for your quick reply .. our company doesn't allow us to post but I am able to email the .pbix if you don't mind that? If you can supply an email address I will send immediately.

thanks
Marc

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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