Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I have 2 tables that have a control # in common. I need to bring in the PO # into the other table based on the common control #.
Tables;
OPENHEAD which has the control number and the PO number.
TRANS has control number but I need to insert a column that pulls the PO number from OPENHEAD.
I do not have these tables related as that breaks other relationships I need active.
I know that LOOKUPVALUE is the equivalent of VLOOKUP but when I try inserting a custom column and use the following string, I get an error that will not let me move forward.
LOOKUPVALUE( 'OPENHEAD'[CUST_PO], 'OPENHEAD'[CONTROL_NO], 'TRANS'[CONTROL_NO])
The OPENHEAD table would have the control number listed multiple times and also the PO number so not sure if maybe that is the reason it is failing.
Please let me know if you see something I am missing. And if the above did not make it clear, I am a novice.
Solved! Go to Solution.
I think it may be the blank control nos in the TRANS table which are causing problems. Try
PO # =
var controlNumber = TRANS[control no]
return IF( NOT ISBLANK(controlNumber),
SELECTCOLUMNS( CALCULATETABLE( TOPN( 1, OPENHEAD, OPENHEAD[ID]),
TREATAS( { controlNumber}, OPENHEAD[control no]) ),
"@val", OPENHEAD[PO #]
) )
If OPENHEAD has a unique identifier for each row you could create the new column like
PO # =
var controlNumber = TRANS[control no]
return SELECTCOLUMNS( CALCULATETABLE( TOPN( 1, OPENHEAD, OPENHEAD[ID]),
TREATAS( { controlNumber}, OPENHEAD[control no]) ),
"@val", OPENHEAD[PO #]
)
thanks for the suggestion but this leads to the same error.
Here are screenshots if that might help.
This is the OPENHEAD table. Each CONTROL_NO is unique and has a CUST_PO column (sometimes they are blank).
This is the TRANS table. I need to insert a column that pulls the CUST_PO info. The common link is that both tables have CONTROL_NO.
Hope that helps to clarify.
Thanks a lot!
I think it may be the blank control nos in the TRANS table which are causing problems. Try
PO # =
var controlNumber = TRANS[control no]
return IF( NOT ISBLANK(controlNumber),
SELECTCOLUMNS( CALCULATETABLE( TOPN( 1, OPENHEAD, OPENHEAD[ID]),
TREATAS( { controlNumber}, OPENHEAD[control no]) ),
"@val", OPENHEAD[PO #]
) )
Still getting the same error. Im not sure that blanks are the issue because I cannot get passed the unexpected token.
Ah, the code I posted was DAX. You need to add it as a new calculated column, not in Power Query.
Gotcha, thanks for pointing me in the right direction. I gave it a go but still getting errors.
See the error at the bottom of this shot. Looks like it does not like that there are multiple lines with the same CONTROL_NO in the TRANS table.
the column needs to go on the TRANS table. I thought that was where you wanted it ?
You are a legend! Thanks so much for your patience on this one. I was trying to put the new calculation under an area where I have lots of other independent calculations and that was the problem like you said. Added under TRANS and good to go! Thanks again!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
88 | |
85 | |
82 | |
65 | |
49 |
User | Count |
---|---|
138 | |
110 | |
104 | |
66 | |
64 |