WOW2022 W45 Tableau vs. Power BI

 WOW2022 W45 Tableau vs. Power BI

Workout Wednesday 2022 W45 challenge by Erica Hughes originally done in Tableau, also recreated in Power BI

In this blog i describe the different approach in both tools.

I might have over complicated my solution in Tableau, so any comments and suggestions are more than welcome.

Preparation

Tableau

I had some difficulties converting the date field properly from text to date/time, so i split the field into 2 columns with space as separator. 


Now i had a proper Date and Time column, but with the time format AM/PM where i needed 24H.
So i created a Calculated Field for the time in 24H format.


Power BI

The same problem here. Trying to convert the date column produced a number of errors so i split this column in Power Query Editor.
First i renamed the DATE column to _DATE so i could create a new Date column.
Having 3 delimiters in the original Date Field made it easy to separate the content.


I also added a custom Date table that will help me with calculating the measures.

Date =
ADDCOLUMNS(
    CALENDAR(
                MIN(WOW2020W45[Date]),
                MAX(WOW2020W45[Date])
),
"Year",YEAR([Date]),
"Month",MONTH([Date]),
"Day",DAY([Date]),
"Hour", HOUR([Date]),
"Day Name",FORMAT([Date],"DDDD"),
"Month Name",FORMAT([Date],"MMMM"),
"Week of Year",WEEKNUM([Date])
)


Building the measures

For this visual i needed 3 measures.
  • The average Waittime for the selected date
  • The average Waitime for the Weekday and Month of the selected date
  • The number of Patients for the selected date

Tableau

First i created a Parameter based on the Date field for the date selection.
Then i added 3 Calculated Fields that i could later use to calculate the measures for the selected date/weekday/month.



I used these fields to calculate the Waittime for the selected date, the Weekday/Month of the selected date and the Patient count for the selected date.



Power BI

In Power BI the date selection is done with a slicer. The filter context will apply to the Patient Waittime and Patient count, so there was no need to create an separate measure for this.
I only needed to create measures for the Waittime for the Weekday/Month.

For the slicer i used the date field from the date table i created. With this i could restrict the average calculation to the Month and Day Name (Weekday) of the selected date using SELECTEDVALUE on the respective columns.

I also needed to remove the filters from the date column with the ALL function. Otherwise i would only get the results from the selected date.

Waittime Weekday/Month =
CALCULATE (
    AVERAGE ( WOW2020W45[PATIENT WAITTIME] ),
    'Date'[Month Name] = SELECTEDVALUE ( 'Date'[Month Name] ),
    'Date'[Day Name] = SELECTEDVALUE ( 'Date'[Day Name] ),
    ALL ( 'Date'[Date] )
)

To display the hours on the x-axis of the chart i created an hour measure based on the Time column i created at the beginning.

_hour = HOUR(WOW2020W45[Time])

Building the visuals

Tableau

For the Patient Waittime I created a Dual-Axis chart with the calculated field i created earlier. 
Hours of my calculated Time field on Columns. On Rows Waittime Date displayed as bars, Waittime Weekday/Month as line.


For the number of Patients it's a simple bar chart with the count of the Patient Id for the selected date and reversed y-axis.


Power BI

While creating the visual in Power BI I encountered some obstacles. 
Firstly, the axis with the hours was not sorted consistently and then the items with no data were not displayed.

To resolve the sorting issue i decided to simply create a new hour column displaying the number as a double digit.


To display the items with no data i created an independent hour table. 

Hours = VALUES(WOW2020W45[Hour])


Using the Hour field from this Hours table, the sort order was correct and it accepts Show items with no data.

Now i just needed to add the Waittime Weekday/Month to the y-axis.

For the number of Patients i just needed a column chart  and invert the range of the y-axis.

Title and Tooltips

Tableau

To display the weekday and month in the Title, i created a calculated date field that would give me the date for the selected day.


I then referenced this field in the title of the line/bar chart.


To display the full hours and minutes in the Tooltip i created a calculation for both.


Then referenced both in the Tooltip.


Power BI

Here i needed to create a measure that would serve as my title text.

Title =
"Average Patient Waittime by hour on "
    & FORMAT ( SELECTEDVALUE ( 'Date'[Date] ), "DDDD, dd. MMMM yyyy" )
    & " compared to an average "
    & SELECTEDVALUE ( 'Date'[Day Name] )
    & " in "
    & SELECTEDVALUE ( 'Date'[Month Name] )

I added this measure to a Multi-row card because, other than the card visual, the text is left aligned instead of centered.


For the Tooltip i also created measures for hour and minutes and another measure that references those fields and then can be used as Tooltip for the visual.

Waittime Hours = INT(AVERAGE(WOW2020W45[PATIENT WAITTIME]) / 60)
Waittime Minutes = INT((AVERAGE(WOW2020W45[PATIENT WAITTIME]) / 60 - [Waittime Hours]) * 60)

Waitime Hours Minutes = [Waittime Hours] & "h " & [Waittime Minutes] & "mins"




From here it was just formatting and bringing all elements together.


The result in both tools is quite similar. Only Tableau offers more flexibility for the title and tooltips, so it's possible to add additional details and formatting.


Comments

Popular posts from this blog

WOW2022 W37 Tableau vs. Power BI

WOW2022 W43 Power BI vs. Tableau

Power BI vs. Tableau - Eine Übersicht