<br />
<b>Warning</b>:  Undefined array key "HTTP_X_WP_TEMPORARY" in <b>/data/0/3/0307764f-852e-4456-9a8c-0bee8b8610da/visualization.sk/sub/blog/wp-config.php</b> on line <b>68</b><br />
<br />
<b>Warning</b>:  Undefined array key "HTTP_X_WP_TEMPORARY" in <b>/data/0/3/0307764f-852e-4456-9a8c-0bee8b8610da/visualization.sk/sub/blog/wp-config.php</b> on line <b>69</b><br />
{"id":46,"date":"2021-02-27T14:43:30","date_gmt":"2021-02-27T14:43:30","guid":{"rendered":"https:\/\/blog.visualization.sk\/?p=46"},"modified":"2021-02-27T17:08:45","modified_gmt":"2021-02-27T17:08:45","slug":"__trashed","status":"publish","type":"post","link":"https:\/\/blog.visualization.sk\/?p=46","title":{"rendered":"Tableau &#8211; Calculated Fields"},"content":{"rendered":"\n<p><strong>Calculated fields <\/strong>add data within Tableau, without changing the underlying data.<\/p>\n\n\n\n<p>For example -&gt; Ratio -&gt; sum(x)\/sum(y)<\/p>\n\n\n\n<ul><li>Fields &#8211; for example &#8211; gdp, population, location, <\/li><li>Functions &#8211; sum, min, max, avg<\/li><li>Operators &#8211; \/,+<\/li><li>Parameter &#8211; variables to replace constant values<\/li><li>Comments &#8211; \/\/, not displayed in the views<\/li><\/ul>\n\n\n\n<p>There are many other ways to create different types of calculated fields:<\/p>\n\n\n\n<ul><li>using different functions &#8211; avg([gdp]), <\/li><li>breaking up a data field, <\/li><li>combine data fields, <\/li><li>or try any other solution. <\/li><\/ul>\n\n\n\n<p>You can create:<\/p>\n\n\n\n<ul><li>calculated strings, <\/li><li>calculated dates, <\/li><li>logic fields, <\/li><li>geographic data.<\/li><\/ul>\n\n\n\n<h2>Calculation Editor <\/h2>\n\n\n\n<ul><li>open the calculation editor:  right-click on a blank space in the Data pane, and select Create Calculated Field. This opens up the calcualtion editor. <\/li><li>Calculated field name -> allows you to identify it quickly in the Data pane.<\/li><li>On the right -> is a full list of all the functions that Tableau recognizes. <\/li><li>Listed functions contains:<ul><li>Syntax &#8211; DATENAME(date_part, date, [start_of_week])<\/li><li>Function description &#8211; Returns a part of given date as a string, where&#8230; <\/li><li>Example calculation &#8211; DATENAME(&#8216;month&#8217;, #2022-04-15#) = &#8220;April&#8221; <\/li><li><\/li><\/ul><\/li><\/ul>\n\n\n\n<h2>String Calculations<\/h2>\n\n\n\n<ul><li>String data is any data that is text, rather than numbers, dates, or locations.<\/li><li>Concatenate strings is put it together. <\/li><li>Operator + <\/li><li>Example : [City] + &#8221; , &#8221; + [Region]<\/li><li>Tableau cannot combine string and integer data. <\/li><li>Data needs to be same data type.<\/li><li>Tableau is read only, so any change is not written back to the database. <\/li><li>Converting data type function:<ul><li>float, int, str<\/li><li>STR( [example] )<\/li><\/ul><\/li><li>If you want to combine the String and Integer fields. You can concatenate the fields by using the str funtion to convert Integer to matching data type.<\/li><\/ul>\n\n\n\n<p>Example:<\/p>\n\n\n\n<ul><li>Create a calculated field that combines the Customer ID and Customer Name fields: <ul><li>In the Data pane, to the right of Dimensions, click the drop-down arrow, and then click Create Calculated Field. <\/li><li>In the top left text box, type &#8220;Customer Number &amp; Name&#8221;. <\/li><li>In the lower left white space, enter this formula:<ul><li>&#8220;Customer #&#8221; + STR([Customer_ID]) + &#8221; &#8211; &#8221; + [Customer Name]<\/li><\/ul><\/li><li>Click OK.<\/li><\/ul><\/li><li>Add the new field to the view to the left of Customer Name, and adjust so all of the text shows. <ul><li>From Dimensions, drag the Customer Number &amp; Name fields to Rows, and drop it to the left of Customer Name. <\/li><li>If a Warning window appears, click Add all members. <\/li><li>In the view, adjust the first column&#8217;s width by hovering the mouse pointer over the right border of the values under Customer Number &amp; Name, and then click and drag to the right. <\/li><li>If you need to, adjust the row height by hovering the mouse pointer over the bottom row border, and then click and drag slightly down.<\/li><\/ul><\/li><li>Make sure the new field&#8217;s values use this format: &#8220;Customer #1887 &#8211; Wendy Hobbs&#8221;. <\/li><li>Remove the original Customer Name field from the view. <ul><li>On Rows, right-click Customer Name, and then click Remove. <\/li><li>Note that your row heights may automatically adjust themselves. Re-adjust them if needed. <\/li><\/ul><\/li><\/ul>\n\n\n\n<h2>Date-Specific Calculations<\/h2>\n\n\n\n<ul><li>calculating difference between dates,  <\/li><li>adding date <\/li><li>using datetime field<\/li><li>todo<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Calculated fields add data within Tableau, without changing the underlying data. For example -&gt; Ratio -&gt; sum(x)\/sum(y) Fields &#8211; for example &#8211; gdp, population, location, Functions &#8211; sum, min, max, avg Operators &#8211; \/,+ Parameter &#8211; variables to replace constant values Comments &#8211; \/\/, not displayed in the views There are many other ways to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[7,8,6],"_links":{"self":[{"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/posts\/46"}],"collection":[{"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":6,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.visualization.sk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}