Working with Data: All the calculations you need t
  • Introduction
  • What is this book?
  • How to Use this Book
  • Document Notes
  • Authors' Thanks
  • Strings
    • Concatenate
    • Split
    • Length
    • Slice
    • Trim
    • Contains
    • Match
    • Replace
    • Upper/Lower Case
  • Numbers
    • Sum
    • Average
    • Roll Ups
    • Round
    • Floor
    • Power
    • Square Root
    • Absolute
  • Dates
    • Date Difference
    • Age
  • Logical
    • Logical Operators
    • If
    • Case / Switch
    • Is Null/Empty
  • General
    • Count
    • Filter
    • Sort
    • Lookup/Join
    • Variables
    • Convert Type
  • Appendix
    • DateTime Parts
    • Helpful Resources
Powered by GitBook
On this page
  • Excel
  • Tableau
  • Alteryx
  • OrgVue
  • tSQL
  • Python

Was this helpful?

  1. General

Convert Type

Excel

  1. Highlight a cell/range of cells; go to Home tab > Font > Options > Number or Right-Click > Format Cells...

  2. Select your desired data type and format

Tableau

There are four options in Tableau for changing data types:

  • During initial data connection - within the data summary window > click the data type symbol of a particular field > String or Number (Whole)/Number (Decimal)

  • Via the user interface (UI) - within the Data Window dragging a field from the Measures pane to the Dimensions pane and vice versa

  • Via field settings - within the Data Window > right-click on a field > Convert to Dimension or Convert to Measure

  • Via a calculated field:

    To String: ~STR!~(‹field›)

    To Number: ~INT!~(‹field›)

    STR([Id])
    INT([Grade])

Alteryx

Use the Select tool (in the Preparation palette)

or To String: ~TOSTRING!~(‹field›«, ,decimals») To Number: ~TONUMBER!~(‹field›«, ignore_errors»)

TOSTRING([Id],4)
TONUMBER([Grade],1)

NB. Content on ignore_errors pending

OrgVue

To String: node.‹field›.~to_s!~ To Number: node.‹field›.~to_n!~

node.id.to_s
node.grade.to_n

tSQL

~CONVERT!~(‹data_type›«(length)», ‹value›, «style»)

SELECT CONVERT(VARCHAR(11),11/04/14,106) AS NewDate
FROM OrdersData

NB. «style» is used to specify the format for date/time value. The following date styles are available:

Style

Date Format

Example

0 or 100

mmm dd yyyy hh:miAM

Sep 20 2016 08:19PM

1 or 101

mm/dd/yy or mm/dd/yyyy

09/20/16 or 09/20/2016

2 or 102

yy.mm.dd or yyyy.mm.dd

16.09.20 or 2016.09.20

3 or 103

dd/mm/yy or dd/mm/yyyy

20/09/16 or 20/09/2016

4 or 104

dd.mm.yy or dd.mm.yyyy

20.09.16 or 20.09.2016

5 or 105

dd-mm-yy or dd-mm-yyyy

20-09-16 or 20-09-2016

6 or 106

dd mmm yy or dd mm yyyy

20 Sep 16 or 20 Sep 2016

7 or 107

mmm dd, yy or mmm dd, yyyy

Sep 20, 16 or Sep 20, 2016

8 or 108

hh:mm:ss

08:41:03

9 or 109

mmm dd yyyy hh:mi:ss:msAM

Sep 20 2016 08:41:03:473PM

10 or 110

mm-dd-yy or mm-dd-yyyy

09-20-16 or 09-20-2016

11 or 111

yy/mm/dd or yyyy/mm/dd

16/09/20 or 2016/09/20

12 or 112

yymmdd or yyyymmdd

160920 or 20160920

13 or 113

dd mmm yyyy hh:mi:ss:mmm (24h)

20 Sep 2016 20:41:03:473

14 or 114

hh:mi:ss:mmm (24h)

20:41:03:473

20 or 120

yyyy-mm-dd hh:mi:ss (24h)

2016-09-20 20:41:03

21 or 121

yyyy-mm-dd hh:mi:ss.mmm (24h)

2016-09-20 20:41:03.473

126

yyyy-mm-ddhh:mi:ss.mmm

2016-09-2020:41:03.473

127

yyyy-mm-ddhh:mi:ss.mmmZ

2016-09-2020:41:03.473Z

130

dd mmm yyyy hh:mi:ss:mmmAM

20 Sep 2016 08:41:03:473PM

131

dd/mm/yy hh:mi:ss:mmmAM

20/09/16 08:41:03:473PM

Python

To String: ~str!~(‹field›) To Number: ~int!~(‹field›)

str(id)
int(grade)
PreviousVariablesNextAppendix

Last updated 5 years ago

Was this helpful?

NB. Thabove example assumes variables have been declared for id and grade. For more information, go to .

General > Variables