cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ucboy4
Regular Visitor

LOOKUP A VALUE FROM FORIGN TABLE AND RETURN A VALUE IN PRIMARY COLUMN IF RESULT IS BLANK

Hi

 

How do I fill up blank rows from a lookup function with values from a column in my primary table.

1 ACCEPTED SOLUTION
gauthamboppana
Solution Supplier
Solution Supplier

@Ucboy4   - There are few ways to do it.  You may create column or measure to get matched items using RELATED function, LOOKUPVALUE function, or FIRSTNONBLANK function .

 

Examples:

 

Column1=RELATED([one side field of relationship])

 

Column1= LOOKUPVALUE(tableA[goal field],  tableA[linked field],  tableB[linked field])) 

 

Column1= CALCULATE (FIRSTNONBLANK ( tableA[goal field], 1 ),FILTER ( ALLSELECTED( tableA), tableA[linked field] = tableB[linked field] ))


Once you look up the value from the foreign table. You can the use IF statement to check whether it is blank or non-blank. ANd, if it is blank, then get value from Primary table column. Example below:

 

Lookup =

Var ForeignValue =  LOOKUPVALUE(tableA[goal field],  tableA[linked field],  tableB[linked field])) 

Return
If (Isblank(ForeignValue), PrimaryTable[Column], ForeignValue)

Hope this helps !   If you need mroe help, please share the screenshots of the tables or upload a sample .pbix file through one drive. Happy to help.

Did I answer your question? Mark my post as a solution! If not, please feel free to ask me.

Also, I would ❤ Kudos if my solution helped.  It is a token of appreciation!

Thank you very much !

 

View solution in original post

3 REPLIES 3
Ucboy4
Regular Visitor

 

 

Perfect!!

 

thanks a million, it worked

@Ucboy4  - Glad it worked !

gauthamboppana
Solution Supplier
Solution Supplier

@Ucboy4   - There are few ways to do it.  You may create column or measure to get matched items using RELATED function, LOOKUPVALUE function, or FIRSTNONBLANK function .

 

Examples:

 

Column1=RELATED([one side field of relationship])

 

Column1= LOOKUPVALUE(tableA[goal field],  tableA[linked field],  tableB[linked field])) 

 

Column1= CALCULATE (FIRSTNONBLANK ( tableA[goal field], 1 ),FILTER ( ALLSELECTED( tableA), tableA[linked field] = tableB[linked field] ))


Once you look up the value from the foreign table. You can the use IF statement to check whether it is blank or non-blank. ANd, if it is blank, then get value from Primary table column. Example below:

 

Lookup =

Var ForeignValue =  LOOKUPVALUE(tableA[goal field],  tableA[linked field],  tableB[linked field])) 

Return
If (Isblank(ForeignValue), PrimaryTable[Column], ForeignValue)

Hope this helps !   If you need mroe help, please share the screenshots of the tables or upload a sample .pbix file through one drive. Happy to help.

Did I answer your question? Mark my post as a solution! If not, please feel free to ask me.

Also, I would ❤ Kudos if my solution helped.  It is a token of appreciation!

Thank you very much !

 

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.