Search code examples
tableau-apimediancalculation

Calculate median sales price with using 3 variables Tableau 10


I would like calculate the median sales price and the median rental price for an apartment in NYC in each of the 5 boroughs, Brooklyn, Bronx Manhattan, Queens and Staten Island. In Tableau the sales and and rentals are groups of ListPrice -- Variables ListPrice is NUMBER(decimal) Type (includes Sales & Rentals, Borough

Any help is appreciated

I tried using Tableau's table calculation feature but that did not work, I tried

WINDOW_MEDIAN(SUM([ListPrice])-1, -1)  

ERROR: WINDOW_MEDIAN is being called with (float, integer), did mean 
(float,integer,integer) 

Data

Type             Borough       ListPrice
RentalType1      Manhattan       $5,000
RentalType2      Bronx           $3,000
RentalType2      Brooklyn        $3,000
SalesType2       Manhattan       $900,000
SalesType1       Brooklyn        $100,000
SalesType1       Bronx           $500,000
SalesType2       Queens          $800,000
SalesType2       Staten Island   $400,000

Solution

  • Table calculations takes 3 arguments, Expression, First row of the partition and last row of the partition. In your formula you haven't given last row of the partition.

    Run the function for type in each Borough and calculate for each Borough.

    So your formula would be:

    WINDOW_MEDIAN(SUM(INT([List Price])),FIRST(),LAST())
    

    enter image description here

    are you looking to get values below:

    Here calculation2 is median value

    enter image description here