Sunday, March 20, 2016

Atlanta Tableau Users Group ATUG - Viz Challenge Data (March 17, 2016)

Yet another fantastic ATUG meeting on Thursday, March 17, 2016! Many thanks to the fine folks at HA&W for hosting our event.

Thank you Andy Piper, John Hoover, and Karen Purcell for making the meeting a success. Last but certainly not least... Nelson Davis for inspiring me. Your sorted-bubbles-on-maps... simply brilliant!

As promised, below is a dashboard I created using the Supreme Court data set. You can download the original data here. The dashboard is still in need of refinement. However, the 2 items of interest from the group were:

1. How to achieve URL Action Filters.
2. How to calculate Year, Month, and Day between any 2 dates.

The URL action filter is fairly straight forward. I just created a calculated field:

"https://en.wikipedia.org/wiki/" +
REPLACE([Name (First)], " ", "_") + "_" + REPLACE([Name (Last)], " ", "_")

...and used it as a hyperlink.

I thought the calculation between two dates was going to be easy. Perhaps I should have started work on it earlier than 9:00PM on a Saturday evening. I still didn't have a very elegant solution by 1:30AM the next morning! My original solution had 3 different year, month, and day calculations. Finally, I came up with this calculation...

// ************************************************************************************************
// Format the difference between 2 dates into a string of ## years, ## months, ## days.
// ************************************************************************************************

IIF([End Date] > [Start Date],
STR(INT((DATEDIFF('month', [Start Date], [End Date]) + IIF(DAY([End Date]) >= DAY([Start Date]), 0, -1)) / 12)) +
" years " +
STR(INT((DATEDIFF('month', [Start Date], [End Date]) + IIF(DAY([End Date]) >= DAY([Start Date]), 0, -1)) % 12)) +
" months " +
STR(DATEDIFF('day', DATEADD('month', INT(DATEDIFF('month', [Start Date], [End Date]) + IIF(DAY([End Date]) >= DAY([Start Date]), 0, -1)), [Start Date]), [End Date]))
,
"") +
" days"

Unless I'm missing something with my testing, this Tableau calculation should work for any 2 dates.