{"id":175,"date":"2012-05-09T15:20:13","date_gmt":"2012-05-09T19:20:13","guid":{"rendered":"https:\/\/jeremystein.com\/brain\/?p=175"},"modified":"2012-05-09T15:20:57","modified_gmt":"2012-05-09T19:20:57","slug":"infopath-conditional-text","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/infopath-conditional-text\/","title":{"rendered":"InfoPath conditional text"},"content":{"rendered":"<p>I&#8217;m using InfoPath 2010.  If I want some text to display a different value depending on the value of a field and I don&#8217;t want to use section hiding to accomplish it, I can use a Calculated Value control like this:<\/p>\n<p>When field1 is &#8220;value1&#8221;, I want to display &#8220;Some Text&#8221;.  When field1 is &#8220;value2&#8221;, I want to display &#8220;Other Text&#8221;.  Here&#8217;s the xpath expression:<\/p>\n<p><code>concat(substring(\"Some Text\", (my:field1 != \"value1\") * 999), substring(\"Other Text\", (my:field1 != \"value2\") * 999))<\/code><\/p>\n<p>How does it work?  Normally, the expression <code>(my:field1 != \"value1\")<\/code> evaluates to 1 since it&#8217;s true.  If you multiply that by 999, it&#8217;s way past the end of the string, and starting the substring there gives you nothing.  But, when it evaluates to 0, the substring function returns the whole string and when concatenated with the other blank strings, gives you just the text you want.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using InfoPath 2010. If I want some text to display a different value depending on the value of a field and I don&#8217;t want to use section hiding to accomplish it, I can use a Calculated Value control like this: When field1 is &#8220;value1&#8221;, I want to display &#8220;Some Text&#8221;. When field1 is &#8220;value2&#8221;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-infopath"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}