Changing text based on a field value
Changing text based on a field value
My need is for a generic report to have it text in a text component changes based on a value elsewhere in the report.
I have looked at the IIF and Switch statements. Those kind of work. My issue is I have say 50 values to equal one text variation and say 15 for another and 10 for yet another text variation.
What is the recommended process for doing something like this. I recall being able to use an IN type statement in Crystal Reports formulas but I am not seeing something like that here.
Suggestions?
I have looked at the IIF and Switch statements. Those kind of work. My issue is I have say 50 values to equal one text variation and say 15 for another and 10 for yet another text variation.
What is the recommended process for doing something like this. I recall being able to use an IN type statement in Crystal Reports formulas but I am not seeing something like that here.
Suggestions?
Re: Changing text based on a field value
Hello, John.
You could use any C# or VB.NET expression in your report.
As a way you could use the Conditions and set the Assign Expression option there.
Please, send us any sample if you still need our help.
Thank you.
You could use any C# or VB.NET expression in your report.
As a way you could use the Conditions and set the Assign Expression option there.
Please, send us any sample if you still need our help.
Thank you.
Re: Changing text based on a field value
Thanks I will give it try with the VB.net coding. If I can just get those curly braces in the correct spot.<smile>. If I get stuck I may need to send a sample.
Re: Changing text based on a field value
Hello, John.
Could you describe your task more detailed with samples and we will try to find a better solution for you?
Thank you.
Could you describe your task more detailed with samples and we will try to find a better solution for you?
Thank you.
Re: Changing text based on a field value
HighAley
I need to create permits. The permit type text changes based on the license type code. A single permit may be related to a group of license type codes. Each group can have varying numbers of codes. So for example:
Permit Text 1 if License Type Code is in group with LTC1,LTC2,LTC7,LTC22, etc.
Permit Text 2 if License Type Code is in group with CTR1,LTC5,LTC6, BC1, etc.
So it needs to print the permit text based on the license type code.
Clear as mud as they say, but that is what I need to code into a report expression somewhere. In Crystal Reports I was able to use formula field to create the logic, I am guessing I need to get that logic into an Expression
I need to create permits. The permit type text changes based on the license type code. A single permit may be related to a group of license type codes. Each group can have varying numbers of codes. So for example:
Permit Text 1 if License Type Code is in group with LTC1,LTC2,LTC7,LTC22, etc.
Permit Text 2 if License Type Code is in group with CTR1,LTC5,LTC6, BC1, etc.
So it needs to print the permit text based on the license type code.
Clear as mud as they say, but that is what I need to code into a report expression somewhere. In Crystal Reports I was able to use formula field to create the logic, I am guessing I need to get that logic into an Expression
Re: Changing text based on a field value
Hello,
You can use IIF() function:
{IIF(License Type = YourCondition, YourTrueValue, YourFalseValue)}
Please send us a test data, we will try to prepare a sample for you.
Thank you.
You can use IIF() function:
{IIF(License Type = YourCondition, YourTrueValue, YourFalseValue)}
Please send us a test data, we will try to prepare a sample for you.
Thank you.
Re: Changing text based on a field value
I got redirected from report building. I am again working on them. Based on the earlier response I have tried creating this code, it is not working. It may be the IIF does not the IN statement
Any suggestions. I do have a number of these to create.
Thanks
John W
Code: Select all
{IIF ({liqMast.LicenseTypeCode} IN ("MBI","BKR","DIM","REP"),"RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20"),)}
{IIF ({liqMast.LicenseTypeCode} IN ("FWN", "MNB", "W32", "WLQ", "WLQBR", "WMB", "WMBBR", "WWN", "WWNMFR", "LQRMFR"),"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35"),)}
Thanks
John W
Re: Changing text based on a field value
It seems it does not like the IN statement, and does not handle a 'list of item'.
Is there a workaround for this, other than listing each of the individual IIF statements?
Is there a workaround for this, other than listing each of the individual IIF statements?
Re: Changing text based on a field value
It also appears you can only run a single IIF, once it returns a true or false value it exits the expression. It does not go to the next IIF statement.
Re: Changing text based on a field value
Hello,
Please try to check the following expression:
Thank you.
Please try to check the following expression:
Code: Select all
{IIF((liqMast.LicenseTypeCode == "MBI" || liqMast.LicenseTypeCode == "BKR" || liqMast.LicenseTypeCode == "DIM" || liqMast.LicenseTypeCode == "REP"), "RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20",
IIF((liqMast.LicenseTypeCode == "FWN" || liqMast.LicenseTypeCode == "MNB" || liqMast.LicenseTypeCode == "W32" || liqMast.LicenseTypeCode == "WLQ" || liqMast.LicenseTypeCode == "WLQBR" || liqMast.LicenseTypeCode == "WMB" || liqMast.LicenseTypeCode == "WMBBR" || liqMast.LicenseTypeCode == "WWN" || liqMast.LicenseTypeCode == "WWNMFR" || liqMast.LicenseTypeCode == "LQRMFR"),"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35", ""))}