• #### Document Why Your Grand Total or Subtotal Isn't Working as ExpectedWhy Your Grand Total or Subtotal Isn't Working as Expected

Tableau does not compute Subtotals and Grand Totals as just an aggregation (Sum, Avg, etc.) of the displayed marks. Instead, Subtotals and Grand Totals are computed as a separate calculation of the Measure at a coarse...
• #### Document Testing Whether ATTR() Returns * (Multiple Values)Testing Whether ATTR() Returns * (Multiple Values)

Description: There are times when we want to know whether ATTR() is returning only one value or multiple values. ATTR() is a helper function that returns a value if there is one and only one value (and/or Null) of...
• #### Document Datetime BinsDatetime Bins

Description: It is often useful to divide up the members of a datetime dimension into uniformly sized bins. Tableau has built-in support for doing this at the level of common datetime units, ranging from years to sec...
• #### Document Continuous BinsContinuous Bins

Description:   It is often useful to bin numbers, and then plot on a continuous axis, or generally use as a continuous (green) pill. This enables adding a reference line.   Tableau has a bin option built i...
• #### Document Replacing No Data with 0 or Another ValueReplacing No Data with 0 or Another Value

Description:   Often times there will be what looks like NULL data in the data, however, it really is No data. (Refer to the blank spaces in the below view).         Example Calculation: &...
• #### Document Year to Date (YTD) from Previous Year and Fiscal YearYear to Date (YTD) from Previous Year and Fiscal Year

Description:   While there is a Year to Date option in a Relative Filter for a date, there is no Year to Date from the previous year. The following formulas use the current Day/Month/Year to determine whether a ...
• #### Document Convert String to Datetime (retaining fractional seconds)Convert String to Datetime (retaining fractional seconds)

Description: Tableau's inbuilt conversion function for converting a string representation of a date and time to a datetime field is DATETIME(). This works fine as long as the precision of the time portion of the fiel...
• #### Document Standard RankStandard Rank

Description:   This is a ranking function with ties. Tied items share the higher rank.         Example Calculation:     IF ISNULL(SUM([Sales])) THEN   NULL ELSE   II...
• #### Document Floor and Ceiling FunctionsFloor and Ceiling Functions

Description:   Tableau does not have native floor and ceiling functions. A floor function maps a number onto the largest previous integer (the biggest integer to the left), a simple ceiling function maps a numbe...
• #### Document Most repeated value in data setMost repeated value in data set

i  have multiple cancellation tickets like 24hrs or 12 pm,Client  want the average to be across all rows but want to show only cancellation tickets  which occurs the most .
• #### Document Random Number GenerationRandom Number Generation

The following two calculations can be used to generate pseudo-random numbers in Tableau.  This works even when using extracts, unlike RAWSQL techniques.   The calculation is a table calc, so random values c...
• #### Document Dynamic Spatial BinningDynamic Spatial Binning

Description:   Sometimes you have points on a map that you want to aggregate, but they don't fall into the state/city/zip hierarchy. This calc provides a way to dynamically bin/group points on a map. The size of...
• #### Document DATEDIFF SemesterDATEDIFF Semester

Description:   How to calculate the semester difference between 2 dates       Example Calculation:   //# 1 - Using DATEDIFF INT(DATEDIFF('quarter',start date,end date)/2)     /...
• #### Document Kaplan Meier Product Limit EstimatorKaplan Meier Product Limit Estimator

Description: The Kaplan Meier product limit estimator is widely used in survival analysis. It is applied in the situation where each event observation records, exclusively, either an outcome, or a censoring at a sing...
• #### Document Quadrature (area under a curve)Quadrature (area under a curve)

Description:   This calculation computes the area under the curve for a function f(x), using the Trapezoid Rule for a non-uniform grid.     Example Calculation:   //The below calculation will co...
• #### Document Convert Epoch Format Timestamp to DatetimeConvert Epoch Format Timestamp to Datetime

Description: Timestamps are often stored as a floating point number representing the number of days since an arbitrary date referred to as the epoch. The fractional portion of this number represents the time of day (...
• #### Document Extract with "or" conditionExtract with "or" condition

Description:   Here's a SQL that I wanted to replicate within Tableau using extract filters, but was unable to.   WHERE   (agg_dim_coordinate_filtered.time_type_code not in ('D', 'W', 'CW'))   OR ...