Hi Tony,
I spent a few hours on friday trying this out.
I made two new mapbasic functions that take a variable number of parameters.
The first one - PredominantVal(expr1, expr1 [, exprn...]) returns the maximum of the values passed in.
The return value has the type of the first expression, so it works for ints, float, string, etc.
The second one tPredominantCol takes the table and the names of the columns as strings.
It returns the name of the column with the predominant value (for the current row)
fetch first from world
print world.Country
print PredominantVal(world.Pop_0_14, world.Pop_15_64, world.Pop_65Plus)
print PredominantCol(world, "Pop_0_14", "Pop_15_64", "Pop_65Plus")
Then i created a tool using python to prompt for a table and then the columns you want.
It currently adds two temporary columns to the table but it could create a temp table instead as you suggested:
It takes the col type from the first col specified.
I could also have used Nested IFF() functions to get the same result without creating new functions.
add column world("MAX_Value" float) from world set to PredominantVal(world.Pop_0_14, world.Pop_15_64, world.Pop_65Plus)
add column world("CAT_Dominant" char(31)) from world set to PredominantCol(world, "Pop_0_14", "Pop_15_64", "Pop_65Plus")

Finally, my other thought was to just extent Max() to take multiple values, then create something like WhichMax() to return the index of the max parameter. A little more work for the tool writer but maybe more generic. Could then do same for Min() and maybe some other functions as well.
Thoughts?
-Bob
ps. I am happy to share the python code if any one wants it. Like this thread if you would like to see it in the product...
------------------------------
Bob Fortin
Software Architect and Distinguished Engineer
MapInfo Pro Development Team
------------------------------
Original Message:
Sent: 12-09-2021 23:24
From: Tony Maber
Subject: Predominance for MapInfo Pro
Hi Bob
Thanks for taking the time to give this some consideration and respond.
Sounds like the IIF() expresions could deliver a partial result (dominant field) but might be a little painful if you've have multiple columns (which would more typically be the case). What this process does not seem to deliver is the maximum value for the dominant field which can be used for the bivariate thematics.
Just for general information, the expressions I use in Excel to prepare predominance data for use are "=MAX(#2:#2)" to generate the dominant value and "=INDEX($#$1:$#$1,MATCH(MAX(#2:#2),#2:#2,0)) to generate the dominant variable heading. These are based on when the first row of the data contained Field Headings and the variables commenced in Column 2.
As mentioned in my earlier post, a lot of the MapInfo Pro users that I work with in the commercial sector are only using it as a small part of their role and would generally not have the capability to build the expressions you suggest themselves. This is why I think that an in-built tool would be beneficial as the potential results can certainly add to the business decision support outputs inherent within MapInfo Pro and grow/strengthen it's role as a mission critical tool.
If it was to be developed as an enhancement, my initial suggestion would be to build a tool with a simple UI that allowed the user to identify the fields to be considered and perhaps output a temporary table that included the map object, it's UID, and the dominant maximum value and dominant field heading as attributes. The user could then use this result to do any thematic mapping or other analysis/visualization and/or could save the result as a permanent table if they felt it was going to be needed at some later stage.
As a long time MapInfo user/supporter, I felt that this could be a positive and relatively simple enhancement given most of the capability is there somewhere anyway, and the benefit would be both in efficiency/useability (through not having to prepare data externally or build complex expression statements in MapInfo Pro) and added analysis capability (always good for users paying their subscription fees to get new features). Would also demonstrate nicely in a new release session and could highlight some of the Precisely Data Catalogue in doing so!
Cheers
------------------------------
Tony Maber
Principal Consultant - Location Analytics & Data
Spatial Decisions
Sydney - Australia
------------------------------
Original Message:
Sent: 12-08-2021 11:59
From: Bob Fortin
Subject: Predominance for MapInfo Pro
Hi Tony,
Have you given some thought as to what you would need in Pro to make this easier?
I think it can be done already by using IIF() or Cond() functions.
You should be able to do the same thing you did in excel inside of Pro with a careful update statement to set the value of a new column.
You can also create an individual value theme without creating a new column:
For World Table shading a county by pop_male vs pop_female (similar to democrat vs republican)
theme on str$(iif(world.pop_male>world.pop_fem, "male", "female"))
we have to use str$ since iif can return any type.

For multiple columns you could use nested IIF() expressions
Perhaps we could add a new functions for example Predominance(expr, column1, label1, column2, label2, column3, label...)
expr would be some way to identify how to compare the values (Max, Min, not sure what else)
Or maybe you would just want some ui to select multiple columns and we build the expression for you.
Thoughts?
------------------------------
Bob Fortin
Software Architect and Distinguished Engineer
MapInfo Pro Development Team
Original Message:
Sent: 12-08-2021 00:13
From: Tony Maber
Subject: Predominance for MapInfo Pro
Hi Stefan
Great response and certainly agree that the key fields are easy to generate if the data you start with is non-spatial and requiring preparation before being imported into MapInfo Pro. These can then be joined to the geographies as per the examples above.
What I should have made more clear is that in the majority of examples above, the original variables data was acquired and already in MapInfo Pro as spatial data. This meant that to produce the predominance required exporting the tabular data, conducting the analysis and then importing the key fields back into MapInfo Pro to do the spatial join before being able to produce the outputs.
Indeed, there are a number of datasets from Precisely and other suppliers/sources (Demographics, Consumer Spend, any Census data, etc) that come spatially enabled with a plethora of attributes that could benefit from predominance as an analysis output. Not having to go through the export/prepare/import/join process would add another form of visualization into MapInfo Pro off the shelf.
Granted that data preparation is a significant element of any project, there are a number of users that I work with in the commercial sector where MapInfo Pro is only a part of their job description, that could struggle with the creation of the key variables in an external product. I'm sure many users would not be aware of the ability to produce predominance in MapInfo Pro (which could be a good opportunity for Precisely to deliver a YouTube video demonstrating the capability or a MapInfo Monday article) regardless of whether the data to begin with is spatial or non-spatial.
If the data is acquired in spatial format it would be much more efficient and powerful to have the capability available without needing extra work to prepare. Alternatively, if non-spatial data is imported without the key predominance already derived but a variety of attributes available, it would be good if MapInfo Pro could do the heavy lifting after joining the data with the geography.
As demonstrated in my original post, MapInfo Pro can certainly deliver the predominance outputs, but only if the data is appropriately prepared externally to allow it to be joined to an existing spatial object. I just wanted to test the appetite of the Community for something like Predominance to be built in to a future MapInfo Pro release as an enhancement. Benefit would be both in efficiency/useability (through not having to prepare data externally) and added analysis capability (always good for users paying their subscription fees to get new features).
Cheers
------------------------------
Tony Maber
Principal Consultant - Location Analytics & Data
Spatial Decisions
Sydney - Australia
Original Message:
Sent: 12-07-2021 03:36
From: Stefan Hausmann
Subject: Predominance for MapInfo Pro
Hi Tony,
from my limited point of view this "Predominance"-View is, as you already wrote, a problem of data preparation only.
The tables you're using as your mapping sources are already the result of an aggregation, pivot-style.
Take your example of professions per state. The normalized form of the not aggregated base data should be something like this: