In the following SSRS expression, I need to remove the comma for the last one...but i don't know which one comes first.
I am getting the result like above. I don't know which one comes first and which comes last. But I don't want the last comma.
Below is the expression I have written:
Ok... wow! It looks to me like you have about 9 iif() tests whose output is concatenated to the next. So
If that's the case you won't know where the final comma is coming from because it could be any one of those tests as long as all the subsequent tests return an empty string (a ""). A quick and dirty solution is to wrap the entire expression in another iif that trims off the final character if it is a comma. Another option might be to change to a leading comma instead of a trailing comma but that might move your surplus comma to the front. So
The real solution though, is better data design. Complex business logic does not belong hidden away in the report. This stuff belongs in a business rules table that you join your data to. You can use TSQL to output the final string. One problem is that it's very hard to read. Sooner or later this code is going to be inherited by someone like me (not so bright) and they are going to curse you for it.