Question

Create attribute based on lookup value in Excel file.

  • 22 March 2022
  • 4 replies
  • 38 views

Badge +7

I'm new to FME. I have an attribute that contains an alphanumeric code. I need to use this code to look up a name in an Excel sheet. I'd like create a new attribute with this name. I think that DatabaseJoiner may be the correct transformer but I haven't been able to get it to work.

 

If possible, if the looked-up name equals "No Data" I'd like to get the name from a different column. Thanks.


4 replies

Badge +2

Hi @datablue​ ,

I think you have the right transformer here too (others like the FeatureJoiner work as well but let's stick with what you have so far). When using the DatabaseJoiner, are your features coming out of the Joined or Unjoined port? To configure this, you should just need to set the Feature Attribute (attribute containing code) and the table field (the same code lookup value in the Excel sheet) and set the Fields to Add so any matched records have the additional attributes.

2022-03-22_13-49-54For the second part, if you include the extra attribute in the Fields to Add parameter, you can use an AttributeManager and Conditional Values after the join to remap the "No Data" values to the other attribute. You can also remove that unwanted attribute in the same AttributeManager in case you don't want it after. See the attached workspace and let me know if that helps.

Badge +7

Hi @datablue​ ,

I think you have the right transformer here too (others like the FeatureJoiner work as well but let's stick with what you have so far). When using the DatabaseJoiner, are your features coming out of the Joined or Unjoined port? To configure this, you should just need to set the Feature Attribute (attribute containing code) and the table field (the same code lookup value in the Excel sheet) and set the Fields to Add so any matched records have the additional attributes.

2022-03-22_13-49-54For the second part, if you include the extra attribute in the Fields to Add parameter, you can use an AttributeManager and Conditional Values after the join to remap the "No Data" values to the other attribute. You can also remove that unwanted attribute in the same AttributeManager in case you don't want it after. See the attached workspace and let me know if that helps.

Thanks for your response. In the DatabaseJoiner parameters, I properly set the Feature Attribute and Table Field. Now, I have 4 records coming out of the Joined port. I don't know how to assign the matches to a new attribute. And I'm not sure how to retain all the records that did not match. I may need to re-visit this tomorrow.

Badge +2

Thanks for your response. In the DatabaseJoiner parameters, I properly set the Feature Attribute and Table Field. Now, I have 4 records coming out of the Joined port. I don't know how to assign the matches to a new attribute. And I'm not sure how to retain all the records that did not match. I may need to re-visit this tomorrow.

Did you set the Fields to Add parameter? This is what merges the additional fields in which can then be renamed (or transformed any other way) using something like an AttributeManager.

 

If you are able to share screenshots of where you are running into trouble I'd be happy to take a closer look.

Badge +7

Thanks for your response. In the DatabaseJoiner parameters, I properly set the Feature Attribute and Table Field. Now, I have 4 records coming out of the Joined port. I don't know how to assign the matches to a new attribute. And I'm not sure how to retain all the records that did not match. I may need to re-visit this tomorrow.

I added two fields to the Add parameter. I'm not sure how to assign one of them to the new attribute.

 

image 

Reply