Wednesday, April 4, 2012

Translate a Field Name into a User-Friendly Field Label

In my last two blog postings and in the one I’m preparing for next week I’ve described techniques that use the GetCurrentField  function. Sometimes, a problem with that function is that it returns a field name which may not be recognizable to the people using a QlikView document. Here’s a technique that can translate the field name into a more user-friendly field label.

First, define a table in the loadscript that lists out the field names you will be using in your cycle groups and the corresponding field labels. Here’s a small example using some SAP field names:

Load * Inline [fldname, fldlabel, fldshort
MATNR, Material, Matl
WERKS, Warehouse, Whse
KUNNR, Customer, Cust];

Now, imagine that you have a chart showing sales totals with a cycle group named SLSCYCLE in the chart dimension that allows the user to click through three values in the cycle group: MATNR, WERKS, or KUNNR. You would like to refer to the current cycle group choice in your chart title but your document users don’t normally use actual field names when they discuss the data. You can use your preferred field label in the chart title with a text expression like this:

='Sales Totals by ' & Only({<fldname={$(=GetCurrentField(SLSCYCLE))}>} fldlabel )

In that expression, the Only function is included as a way to use Set Analysis syntax to retrieve the user-friendly  fldlabel value corresponding to the field name.
The expression could have used the alternate short label fldshort in a place where shorter text is required. The little FLD_LABEL_MAP table could also contain other data elements related to the field such as the name in a different language or a short piece of help text.

 *  *  *


Spectra said...

Thank you!
I've been looking for two hours for such a solution.

Anonymous said...

I love it and will be promptly applying it to an existing project I have started which has somewhere in the vicinity of 160 fields (named nicely for development, but not so nice for user-display).

Any ideas on user-friendly display of labels in the 'CurrentSelections' box? I'm now noodling on whether this approach could be possibly adapted...thought or suggestion would be much appreciated.

-TB said...

You won't be able to modify the CurrentSelections box to show user-friendly labels. You may be able to build an acceptable text box that checks current selections for a limited number of fields and then displays the field and/or a user-friendly label and the currently selected values. That approach may be too complicated for 160 fields, though.

I sympathize with the problem. I have worked with a developer who firmly believed that he could abbreviate anything in three characters or less.

Good luck,