mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
7.8 KiB
1 lines
7.8 KiB
"use strict";(self.webpackChunknoco_docs=self.webpackChunknoco_docs||[]).push([[9449],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>f});var a=n(67294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=a.createContext({}),d=function(e){var t=a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=d(e.components);return a.createElement(s.Provider,{value:t},e.children)},u="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),u=d(n),c=r,f=u["".concat(s,".").concat(c)]||u[c]||m[c]||i;return n?a.createElement(f,l(l({ref:t},p),{},{components:n})):a.createElement(f,l({ref:t},p))}));function f(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,l=new Array(i);l[0]=c;var o={};for(var s in t)hasOwnProperty.call(t,s)&&(o[s]=t[s]);o.originalType=e,o[u]="string"==typeof e?e:r,l[1]=o;for(var d=2;d<i;d++)l[d]=n[d];return a.createElement.apply(null,l)}return a.createElement.apply(null,n)}c.displayName="MDXCreateElement"},6458:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>l,default:()=>m,frontMatter:()=>i,metadata:()=>o,toc:()=>d});var a=n(87462),r=(n(67294),n(3905));const i={title:"Conditional expressions",description:"This article explains various conditional expressions that can be used in formula fields.",tags:["Fields","Field types","Formula"],keywords:["Fields","Field types","Formula","Create formula field","Conditional expressions"]},l=void 0,o={unversionedId:"fields/field-types/formula/conditional-expressions",id:"fields/field-types/formula/conditional-expressions",title:"Conditional expressions",description:"This article explains various conditional expressions that can be used in formula fields.",source:"@site/docs/070.fields/040.field-types/060.formula/050.conditional-expressions.md",sourceDirName:"070.fields/040.field-types/060.formula",slug:"/fields/field-types/formula/conditional-expressions",permalink:"/fields/field-types/formula/conditional-expressions",draft:!1,editUrl:"https://github.com/nocodb/nocodb/tree/develop/packages/noco-docs/docs/docs/070.fields/040.field-types/060.formula/050.conditional-expressions.md",tags:[{label:"Fields",permalink:"/tags/fields"},{label:"Field types",permalink:"/tags/field-types"},{label:"Formula",permalink:"/tags/formula"}],version:"current",sidebarPosition:50,frontMatter:{title:"Conditional expressions",description:"This article explains various conditional expressions that can be used in formula fields.",tags:["Fields","Field types","Formula"],keywords:["Fields","Field types","Formula","Create formula field","Conditional expressions"]},sidebar:"tutorialSidebar",previous:{title:"Date functions",permalink:"/fields/field-types/formula/date-functions"},next:{title:"Date Time",permalink:"/fields/field-types/date-time-based/date-time"}},s={},d=[{value:"Conditional expressions",id:"conditional-expressions",level:3},{value:"Related Articles",id:"related-articles",level:2}],p={toc:d},u="wrapper";function m(e){let{components:t,...n}=e;return(0,r.kt)(u,(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h3",{id:"conditional-expressions"},"Conditional expressions"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Name"),(0,r.kt)("th",{parentName:"tr",align:null},"Syntax"),(0,r.kt)("th",{parentName:"tr",align:null},"Sample"),(0,r.kt)("th",{parentName:"tr",align:null},"Output"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("strong",{parentName:"td"},"IF")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"IF(expr, successCase, elseCase)")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"IF({field} > 1, Value1, Value2)")),(0,r.kt)("td",{parentName:"tr",align:null},"successCase if ",(0,r.kt)("inlineCode",{parentName:"td"},"expr")," evaluates to TRUE, elseCase otherwise")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("strong",{parentName:"td"},"SWITCH")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"SWITCH(expr, [pattern, value, ..., default])")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"SWITCH({field}, 1, 'One', 2, 'Two', '--')")),(0,r.kt)("td",{parentName:"tr",align:null},"Switch case value based on ",(0,r.kt)("inlineCode",{parentName:"td"},"expr")," output")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("strong",{parentName:"td"},"AND")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"AND(expr1, [expr2,...])")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"AND({field} > 2, {field} < 10)")),(0,r.kt)("td",{parentName:"tr",align:null},"TRUE if all ",(0,r.kt)("inlineCode",{parentName:"td"},"expr")," evaluate to TRUE")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("strong",{parentName:"td"},"OR")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"OR(expr1, [expr2,...])")),(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"OR({field} > 2, {field} < 10)")),(0,r.kt)("td",{parentName:"tr",align:null},"TRUE if at least one ",(0,r.kt)("inlineCode",{parentName:"td"},"expr")," evaluates to TRUE")))),(0,r.kt)("admonition",{type:"tip"},(0,r.kt)("p",{parentName:"admonition"},"Logical operators, along with Numerical operators can be used to build conditional ",(0,r.kt)("inlineCode",{parentName:"p"},"expressions"),". "),(0,r.kt)("p",{parentName:"admonition"},"Examples:"),(0,r.kt)("pre",{parentName:"admonition"},(0,r.kt)("code",{parentName:"pre"},'IF({marksSecured} > 80, "GradeA", "GradeB") \n')),(0,r.kt)("pre",{parentName:"admonition"},(0,r.kt)("code",{parentName:"pre"},"SWITCH({quarterNumber}, \n 1, 'Jan-Mar',\n 2, 'Apr-Jun',\n 3, 'Jul-Sep',\n 4, 'Oct-Dec',\n 'INVALID'\n)\n"))),(0,r.kt)("h2",{id:"related-articles"},"Related Articles"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"/fields/field-types/formula/operators"},"Numeric and Logical Operators")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"/fields/field-types/formula/numeric-functions"},"Numeric Functions")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"/fields/field-types/formula/string-functions"},"String Functions")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"/fields/field-types/formula/date-functions"},"Date Functions"))))}m.isMDXComponent=!0}}]); |