MAPKEYS function

When you fetch data for any control using functions like Left JOIN(), Right JOIN(), and so on you will find that the control populates its headers based on column names by default. Now if you want to customize them and also use them in a certain order, you can make use of the MAPKEYS function for the purpose. So you would be mapping the keys to the new key names and displaying them likewise.

You can map the key name using the colon ( : ) or AS keyword. At the same time you can also have a logical arrangement as per your scenario by rearranging the order in the MAPKEYS function when mapping the key.

Syntax

MAPKEYS([ArrayOfJsonobjects.Key1,ArrayOfJsonobjects.Key2,…],“newkeyname1,newkeyname2,…”)

Or,

MAPKEYS([ArrayOfJsonobjects.Key1,ArrayOfJsonobjects.Key2,…],“newkeyname1:Key1,newkeyname2:Key2,…”)

Or

MAPKEYS([ArrayOfJsonobjects.Key1,ArrayOfJsonobjects.Key2,…],“Key1 AS newkeyname1, Key2 AS newkeyname2, …”)

Where,

  • Newkeyname<1>: is the new label assigned to the respective key
  • Key<1>: is the default key name or label of the respective header of the populated columns from any source .

So for example,
MAPKEYS(LOOKUP([table1.name,table1.id]), “username, userid”)

OR

MAPKEYS(LOOKUP([table1.name,table1.id]), “username:name, userid:id”)

OR

MAPKEYS(LOOKUP([table1.name,table1.id]), “name AS username,id AS userid”)

Will result into
[{“usernaname”: “someusername”, “userid”:“someid”}]

This will set the key name of index 0 value to username & index 1 to userid

To further understand how to use the MAPKEYS function visit this article here.