Select to view content in your preferred language

Can I have max() return the name of the field found to have the calculated max value in my report?

468
2
09-16-2022 01:17 PM
MattEdrich
Frequent Contributor

Hello,

I am trying to create a conditional in my report regarding the name of whatever observation happens to have a certain max value. In my case, I need to report the highest appurtenance on a telecom tower, and if that appurtenance is or is not the lightning rod. I have the survey set up so that the technician answers whether or not the lightning rod is the highest appurtenance, so that part is easy. So is finding the highest appurtenance. 

What is holding me up is that if the lightning rod is not the highest appurtenance, I would like to automate the reporting of the name of the appurtenance that is the highest. Is this possible? I want to believe it is through some kind of getValue usage, but I am not sure what that is.

My max calculation is thus: max(${lightning_agl}, ${sector_eq_shield_agl}, ${lone_antenna_shield_agl})

Any help with the syntax here would be really appreciated. Thank you!

0 Kudos
2 Replies
LaurenceTait
Frequent Contributor

Your 'max' calculation should work fine. All you need to do after that is construct a nested 'if' statement that returns the name based on the that max value. For example, if  you've assigned the Max calulation the name "heighest", then the following will work:

if(${lightning_agl_height} = ${heighest},'lightning', if(${sector_eq_shield_agl} = ${heighest},'sector_eq_shield', if(${lone_antenna_shield_ag} = ${heighest},'lone_antenna_shield'),''))

 

 

0 Kudos
MattEdrich
Frequent Contributor

Thank you very much for the response! I tried to apply your solution to my report, but alas, I am missing something in the syntax still. I actually wasn't aware that you could indeed nest `if` statements in report templates! So I am sure that is where I am going wrong. 

Here's what I've got at the moment, syntactically:

${highest_appurt_agl}’
${if(${sector_eq_shield_agl}=${highest_appurt_agl},’sector_eq_shield’, if(${lone_antenna_shield}=${highest_appurt_agl},’lone_antenna_shield’),’’))${/}

Where am I going wrong here?

0 Kudos