Skip to content

Instantly share code, notes, and snippets.

@rcackerman
Last active April 9, 2018 14:59
Show Gist options
  • Select an option

  • Save rcackerman/968d336174c9dbd5bd51a8a64bf6540f to your computer and use it in GitHub Desktop.

Select an option

Save rcackerman/968d336174c9dbd5bd51a8a64bf6540f to your computer and use it in GitHub Desktop.
Tableau Snippets

Extract the PL # from PDCMS Charge

if REGEXP_MATCH([Tc Pl#], '^A[0-9]') = true
then REPLACE([Tc Pl#], 'A', '')
else [Tc Pl#]
END

Extract the 'A' from PDCMS charge

REGEXP_EXTRACT([Tc Pl#], '^(A)[0-9]+$')

Show the charge family (ie 220.xx, 120.xx)

IIF(
    REGEXP_MATCH(left([TC Without A], 3), '[0-9][0-9][0-9]'),
    LEFT([TC Without A], 3), //display if first 3 characters are numbers
    [TC Without A] // otherwise display the full charge
)

Check if the charge is violent

iif(
    REGEXP_MATCH([Top Charge Type], 'FV'),
    'Violent', 'Non-Violent')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment