Trouble Using IF Statements in Shape Data.

Started by conmccar7, June 14, 2023, 04:16:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

conmccar7

Hi All,

I'm a bit new to using some of the more advanced functions in the Shapesheet and I'm having some trouble using IF statements and nested IF statements in Shape Data. Using Visio 2019

What I'm ultimately trying to do is setup some shape data that will change as a result of a different property being changed.

I have Prop1 setup as a fixed list with options of "One" "Two" and "Three". And Prop2 setup as a string.



In Shapesheet, I have the Value for Prop2 set as:

=IF(Prop.Prop1="One","A",IF(Prop.Prop1="Two","B",IF(Prop.Prop1="Three","C","")))

I close the Shapesheet and change the value of Prop1 to "Two", but Prop2 does not change from "A" to "B".

I've also tried doing this as:

=IF(STRSAME(Prop.Prop1,"One"),"A",IF(STRSAME(Prop.Prop1,"Two"),"B",IF(STRSAME(Prop.Prop1,"Three"),"C","")))

And Prop2 changes from "A", but only to a blank and not "B" or "C" like it should. Can anyone point me in the right direction for fixing this?

Thank you in Advance!



vojo

user.cell2 = if(same(props.prop1.value, "A"),<AAA>,FALSE)
user.cell3 = if(samestr(props.prop1.value, "B", <BBB>,FALSE)
user.cell4 = if(samestr(props.prop2.value, <golden string>),TRUE,FALSE)

props.prop1.value = "<input string>
props.prop2.value =<"string">

user.cell1 = if(user.cell2, User.cell2,if(user.cell3, User.cell2, if(user.cell4, user.cell4,"deadbeef"),"NA"),"badness")

comments
- for easy debug use lots of cells
- start with a simple one like if (user.cellx = 1, 100,-100)
- the else clause can be another if then else, an else statement or jus a simple "comma bracket)...need the else clause noted not just hanging out there.
- can have up to 126 nested if then else in a single cell....very tough to read and figure out which one triggered.

wapperdude

#2
To the immediate question, the issue is syntax.  If Prop.prop1 uses fixed list format, that would be something like "One;Two;Three".  Then, in this case, the IF construct you have works fine.  However, if the format is merely string, then, you must either enter the value without quotes, e.g.,  One.  If you actually enter "Two" which includes the quotes, then your IF Strsame test must be like this:  Strsame(Prop.prop1,"""Two""").

In Vojo's reply, it is not necessary to type the ".value".  Visio defaults to the Value cell.  If fact, after Visio accepts the entry, it will truncate and drop the .value from the formula.
Visio 2019 Pro

conmccar7

Thank you both so much for the help! I was finally able to get the syntax right and make this work.