If Statement and Excel

I am trying to assign a “KeyNote Text” value from an excel file based on the input “Key Value”.

If “Key Value” = 1 then Dynamo will look for “1” in the first column of excel. Once it finds “1” then it will assign the text, from Column 2, into “KeyNote Text”.

Could someone please help out?

Thanks in advance


use Dictionary
Transpose the result from excel with Transpose Node then use Dictionary by Dictionary.ByKeysValue node and in put the values in it
then use valuesatkeys Node to get what you want

1 Like

@khuzaimah.ElecEng, am I close?

the input for Dictionary.ByKeysValues
after transpose use GetItemAtIndex Node @ 0 and make it an input for Keys.
use use GetItemAtIndex Node @ 1, and make it an input for Values
other that every thing is fine

1 Like

@khuzaimah.ElecEng, Its giving me a warning.

the input suppose to be string.
in the Data.ImportExcel, make a “True” input for " Read as a String "

now I am very close! but I have a similar error for the Dictionary.ValueAtKeys

the input for ‘keys’ in Dictionary.ValueAtKeys should be string also … use StringFromObj Node before input it

Still giving me same warning

can you upload the file and the excel ?

@khuzaimah.ElecEng, I sent you a link with my files in a private message. thank you for your help!

as you see there is something weird about Dictionary node you have used ,so i have added mine, please make sure it is from OOTB nodes ( from built it nodes in Dynamo ) not from package, otherwise update Dynamo to latest version

also i have added some modifications as you see in picture

best of luck

1 Like

Yes, I was using a different node called the same. I changed it and it works!!! Thank you very much!