3 Replies Latest reply: Mar 8, 2016 3:06 AM by Samuel Mostert RSS

    Labels for aliases for field names

    Samuel Mostert

      Hi Guys

       

      I've googled myself to death on the interwebs and can't find any solution.

       

      I have a table of data that I import with field names for example

       

      Field_abc
      Field_def

      Field_ghi

      Field_jkl

      ...etc

       

      I design the model using these original field names, however they don't mean anything much to the end user. So what I need is to assign user friendly labels that can be referenced in the headings and charts instead of these database fields.

       

      My current approach is to load an inline table where the original field name is specified as well as an alternative user friendly field like ...

       

      FieldNameAlternatives:

      Load * inline [

      _ORIGINALFIELDNAME,     _ALTERNATIVEFIELDNAME

      Field_abc,                            Product
      Field_def,                             Country

      Field_ghi,                             Region

      Field_jkl,                              Segment

      ...etc

      ];

       

      Now I can come right with a 'RENAME FIELDS USING FIELDMAP' process ....

       

      Buuuuuut .... it REPLACES the original field name with the alternative field name.

       

      Normally I won't mind, but in this case (and for future dynamic design), I need to RETAIN the original field name as well as the new alternative field name.

       

      The obvious answer is to do something like

       

      Load

      Field_abc AS Product,

      Field_def AS Country,

      Field_ghi AS Region,

      Field_jkl AS Segment,

      etc....

       

      But this balloons the data since I'm not allowed to drop the original field. I'm pretty sure I need to use an 'applymap' function, but I'm not getting it right.

       

      Any help or direction would be much appreciated!

       

      Thanks

      Samuel

        • Re: Labels for aliases for field names
          Settu Periyasamy

          May be there is a good suggestion. I would do like this..

           

          1. Export all the Fields to the excel (use the for loop in script or $Field in front End)

          2. Give the Meaningful name of the Field.

          3. Load the Excel file.

          4.  'RENAME FIELDS USING FIELDMAP' process - In the End of the Script

          5. Maintain the Excel Sheet (Whatever field added in the Script, Need to Add in Excel also)

          • Re: Labels for aliases for field names
            Marcus Sommer

            It isn't possible to have to two field-names for one field. If you really want to keep the origin field-names within the enduser-reports you will need to translate them then with an expression - best practice is to use a 3-tier data architecture with generator --> datamodel --> report and change the fieldnames on the scriptend from datamodel or from report the origin field-names into user-friendly ones per rename-statement.

             

            The above mentioned expression alternatively requirred an additionally table similar like a mapping table and could look like:

             

            only({< OriginFieldname = {'YourUsedField'}>} UserfriendlyFieldname)

             

            maybe shortened per variable like:

             

            var:

            only({< OriginFieldname = {$1}>} UserfriendlyFieldname)

             

            and then as expression:

             

            $(var('YourUsedField'))

             

            but you will need to write this probably very often and therefore it's best practice to use the userfriendly field-names already within the script.

             

            - Marcus