Skip to main content

Posts

Showing posts with the label tableau if

Tableau Color indicator from previous day to today.

Tableau Color indicator to compare sales previous day to today. The calculation uses LOOKUP function to get the rate for previous day. (It is like Today's value - Previous days value)/Previous days absolute value. If the above > 0 then "Color1" Else If the above <0 then "Color2" IF (ZN(([Success Rate])) - LOOKUP(ZN(([Success Rate])), -1)) / ABS(LOOKUP(ZN(([Success Rate])), -1))=0 then "white" ELSEIF (ZN(([Success Rate])) - LOOKUP(ZN(([Success Rate])), -1)) / ABS(LOOKUP(ZN(([Success Rate])), -1))>0 then "green" ELSEIF (ZN(([Success Rate])) - LOOKUP(ZN(([Success Rate])), -1)) / ABS(LOOKUP(ZN(([Success Rate])), -1))<0 then "red" END

Tableau Logical Functions

Tableau Logical Functions Why do we use logical calculations? Logical calculations allow you to determine if a certain condition is true or false (boolean logic). For example, you might want to quickly see if sales for each country you distribute your merchandise to were above or below a certain threshold. Function Syntax Description IN <expr1> IN <expr2> Returns TRUE if any value in <expr1> matches any value in <expr2>. The values in <expr1> can be a Set, list of literal values, or a combined field. Examples: SUM([Cost]) IN (1000, 15, 200) [SET] IN [COMBINED FIELD] AND IF <expr1> AND <expr2> THEN <then> END Performs a logical conjunction on two expressions. Example: IF (ATTR([Market]) = "Africa" AND SUM([Sales]) > [Emerging Threshold] )THEN "Well Performing" CASE CASE <expression> WHEN <value1> THEN <return1> WHEN <value2> THEN <return2> ... ELSE <default return> END Pe...