Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Displaying a text based on condition of the other column of the same report
italugyaja
Hi,
I have a report which has a column called WORKNO WORKTYPE and a third column which will display Yes or No depending on the value of WORKTYPE
For Example
If the Column WORKTYPE has value CM it should display "corrective Maintenace " in this third column else it should display " Not CM"
Can anyone tell me how a column binding [like this third column ] here can be conditionally configured on the basis of other columns that are proesent in the report .
The report is a straght forward ,it contains only 3 columns.
and runs on a simple query Select WORTYPE,WORKNO from WORKORDER;
Please help!!!
Thanks.
Find more posts tagged with
Comments
Monma
I am not sure I understand what you are trying to do. But you could easily modify your query to something like this (for mysql) and it will do it:
Select
WORTYPE,
WORKNO,
if (WORKTYPE = "CM", "corrective Maintenance","No CM") as OtherColumn
from WORKORDER;
Then you set your table and bind to the data set.
Another approach it to add a computed column to the data set that will do what you want.
A third approach is when you bind the table to the dataset you will add an element and define using an expression that does the if statement.
Hope this will help.
italugyaja
Can you elaborate on the third apporach by giving the exact condition clause
see i have tried in this way
1) on the blank template
2) i added table 3 by 1 row
3) dragged and drop first 2 columns there namely workno and worktype
4) I added a data set column which canbe result of an expression..
now it is here where i want to write my logic for showing Cm or not Cm based on worktype.
Can you give me the exact expression of what to write.
I guess this is the last approach that u were suggesting ,if its not then kindly elaborate on whts ur way out.
I tried to do it from sql query by using DECODE but i guess BIRt is nt accepting that .Any other way in sql in which i can create a dummy column at runtime in the dataset and then drag this dummy column in my 3 rd column to show my relevant text i.e Cm or not CM.
Regards,
AJ
Monma
Ok, if you want to use the 3rd approach do the following:
1 - Make sure that the 3rd colum detail cell does not contain anything (delete anything that you added)
2 - Click on cell and press the right button
3 - Select: Insert > Data
4 - in the Dialog window enter:
a name for the Column Binding
a display name for the same
you can keep data type as any
in expression press on the Fx button
5 - In the text field you would paste
if (row["WORKTYPE"] == "CM") {
"Corrective Maintenance";
} else {
"No CM";
}
This should do it.
You can build any javascript you like really.
Hope this will help. Take Care.
italugyaja
Thanks a million it worked ....
**** Bless you!!!
Regards
AJ!!!
Monma
You are welcome.
johnw
You could also use a Map and not have to maintain any Javascript.
Select your cell. In the property Editor at the bottom of Eclipse, choose Map. Click Add. For Expression, chose your Column that has your value condition (WORKTYPE). Set Equals to as your compare operator. Then set value to Select List, and choose CM.
Then set your Display Message as "Corrective Maintenance".
When you run your report, cell will read "Corrective Maintenance", otherwise it will read its default value. If you want that default value to be "No CM", then just set that as your expression for that data element. A little easier than Javascript if your not a programmer. If you have a lot of conditions, the Map will be a lot easier than a huge If/Else statement or a switch statement.