---
title: "Calc: using field from another entity"
url: "https://openforis.support/questions/157/calc-using-field-from-another-entity"
tags: ["calc"]
status: "answered"
score: 0
answer_count: 1
asked: "2015-01-20T03:24:09"
last_activity: "2015-01-20T14:23:35"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# Calc: using field from another entity

Asked by Lauri (OF) on 2015-01-20

Hi, 
I tried to get more results for Plot level, as number of species in each plot. There this line

*regenSpecies <- sqldf( "SELECT plot_id_ , regen_species_code AS species_code FROM regen " );* 

caused an error, and I checked in RStudio that *regen$regen_species_code* was not read in *dbGetQuery* clause. 

I could solve this by adding a "fake" line into previous "Regen - Count total" module as:
*test <- regen$regen_species_code*

BUT, it so that only those fields are read in which are written into the code under that particular entity?

Cheers, Lauri


## Answer (score 0, by Mino Togna on 2015-01-20)

Link: https://openforis.support/questions/157/calc-using-field-from-another-entity/158

Dear Lauri,

If you want to have variables read for a specific entity (e.g. regen), you need to add that variable in a calculation step that uses that entity (as you did in the regen – count total). 

Afterwards that variable can be used in another calculation step.

I think you can also add a simple comment that includes the variable. e.g.:
 # regen_ species_ count 

in the regen – count total calculation step.
 
Mino
