Using SSRS's =Lookup in ignition

Hello everyone.

I have an issue with porting SSRS's =Lookup function into ignition's reporting.

My SSRS's lookup function:
=Lookup("DAYSHRT" , Fields!Id.Value , Fields!DAYFULL.Value,"Timestamps")

I pass "MND" as DAYSHRT and in return i get a full name of the week "Monday".

I need this to fill my column names with expressions where each column name will be a separate lookup with "MND", "TUESD" etc.

How do i approach this?
I'm stuck in a loop of my own trials, errors and mistakes.

Thank you in advance!

Mon, Tue, Wed, Thu, Fri, Sat, Sun are the standard day of week abbreviations. I recommend that you use those as your users will be familiar with them and they are unambiguous - unless you're working in some other language?

1 Like

You should rewrite your column names either in your data source directly (as in the SQL query or whatever other source) or if that truly isn't possible, use a script data source to rewrite the dataset headers once, using system.dataset scripting functions.

Using keychain expressions for this would be possible, but a maintenance nightmare.

3 Likes

This is somewhat close to what i need, I'm gonna sniff around.

After reading how i formatted my post, i've decided that i'm gonna rewrite it:

I need to have some script in each column of my header in my reporting table, so that column's value is based on script's outcome. For example:
If i have value MND in first column of my header, this value should be passed to a script that looks up the translation table and returns a value based on currently selected language (the language part is done).

In SSRS each column header has a short lookup expression and it solves the problem. Here i worked around it by making a separate SQL Query for each column in Reporting->DATA tab ->Data sources which works, but i find it disgusting compared how elegantly its solved in SSRS due to a lot of queries which differ only by the hard-coded searched value. I'd like to pin each header's value to one script that would handle all of the columns. To do that, i'd need to know: how can i reference to a certain header row in my script?
I'm starting to think that this approach is impossible.

SSRS's header expression I've mentioned above:
Header 1:
=Lookup("MND" , Fields!Id.Value , Fields!Translation.Value,"Translations")
Header 2:
=Lookup("TSD" , Fields!Id.Value , Fields!Translation.Value,"Translations")
etc.

Desired outcome visualised:

This was only used as a form of example so it would be easier to understand the issue, but you are right - I'am working with other languages, so thats why i need to use some form of Lookup based on current language.

One option:
Lean into Ignition's translation manager functionality.
Put MND, TSD, etc into the translation manager, with translated values for each locale.
I'm assuming you're accepting a locale string report parameter based on your two output examples.

Then, in a script data source, do something like this:

weekdays = ["MND", "TSD", "WED"] # etc
translated_weekdays = [system.util.translate(weekday, data["locale"]) for weekday in weekdays]

data['weekdays'] = system.dataset.toDataSet(weekdays, [translated_weekdays])

To look up translations for the given inputs. Then in your actual report, just drop the MND value from your data sources into the table header and it'll automatically look up the first row and return it for you.

Another option would be to actually change the dataset headers, like I mentioned in my first post, but if you're already expecting this to work another way this is closer to what you're looking for.

3 Likes

Can you not specify the locale to SSRS in the query and return the day of the week in the requested language automatically - probably using the "ddd" format. I've never heard of SSRS before but I'd imagine it should be possible.

Thats actually such a good idea!
I'm gonna definitely give this approach a try, thank you very much!

I'm gonna respond to this once i get it working to share the solution.