MapInfo Pro

 View Only
  • 1.  Statistic Calculation in MapInfo

    Posted 11-30-2023 04:41

    Hi Everyone. Good day.

    How can we calculate median in MapInfo?



    ------------------------------
    Wahida Latif
    Map Information Solutions Sdn Bhd
    KUALA LUMPUR
    ------------------------------


  • 2.  RE: Statistic Calculation in MapInfo

    Employee
    Posted 11-30-2023 10:27

    Hi

    Out of the box, MapInfo Pro doesn't support the Median aggregate, unfortunately.

    I'd recommend giving this idea a vote.

    Is it just for a single column you want to calculate this value?



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 3.  RE: Statistic Calculation in MapInfo

    Posted 11-30-2023 19:33

    Hi Peter, for now just for a single column. Can we do it through map basic ?



    ------------------------------
    Wahida Latif
    Map Information Solutions Sdn Bhd
    KUALA LUMPUR
    ------------------------------



  • 4.  RE: Statistic Calculation in MapInfo

    Posted 11-30-2023 22:03

    Hi Wahida,

    I came up with the following SELECT statements for doing this.  Perhaps there is a way of combining these, but I had trouble due to restrictions on how RowID can be used.  Anyway, this should get you the result you need.  In the below, I have used a table called "Scores" and I am finding the median of the values in the "Score" column of this table.  These SELECT statements can be executed in either the SQL or MapBasic window.  The result will be returned in the "Scores_median" query table.

    ' Order the values:
    SELECT Score
    FROM Scores
    ORDER BY Score
    INTO Scores_ordered

    ' Count the number of records in the table:
    SELECT Count(*) As "record_count"
    FROM  Scores
    INTO Scores_count

    ' Retrieve the median:
    SELECT Scores_ordered.Score As "median_score"
    FROM Scores_ordered
    WHERE RowID = ANY (SELECT Round(Scores_count.record_count/2, 1) FROM Scores_count)
    INTO Scores_median



    ------------------------------
    James Nolet
    GIS Manager
    Caf Consulting
    Mentone office, VIC, Australia
    ------------------------------



  • 5.  RE: Statistic Calculation in MapInfo

    Posted 11-30-2023 22:54

    Hi James.. 
    Thank you for your sharing. Its work! 
    Here is the mapbasic for those who might need it later.



    ------------------------------
    Wahida Latif
    Map Information Solutions Sdn Bhd
    KUALA LUMPUR
    ------------------------------