AnsweredAssumed Answered

Help with dynamic label python code

Question asked by seanedwards on Jul 14, 2016
Latest reply on Jul 15, 2016 by rvburton

Hello friend. I am pretty basic with Python and have a question about writing out a label.

I have an attribute table with multiple fields with floating point acreages in the fields. Not all of the fields necessarily have to contain a value; most of them are <Null>.

I am trying to build a label expression for a data driven map book that looks at the fields, and if it it has a value, add it to the label with leading text, then look at the next field. So far, I have using the IF statement and once the statement is true, it stops and does not search for the other true values.

Is there any If-and statement that I can use?

 

My code:

Function FindLabel ( [BLM] , [BR] , [Private] , [SITLA] )

  if ( ( [BLM] ) > 0) then 

    FindLabel = "BLM: " + [BLM] + " acres"

  elseif  ( ( [BR] ) > 0) then 

    FindLabel = "BR: " + [BR] + " acres"

  elseif  ( ( [Private] ) > 0) then 

    FindLabel = "Private: " + [Private] + " acres"

  elseif  ( ( [SITLA] ) > 0) then 

    FindLabel = "SITLA: " + [SITLA] + " acres"

  end if

End Function

 

Assuming that there were acreages in each of the fields except [BR], I would want the label to read

 

BLM: 44.59 acres

Private: 89.01 acres

SITLA: 1.89 acres

 

Thanks for any help!

Attachments

Outcomes