COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: vharcourt on 20 Jan 2018 03:47:18 PM

Title: Name Selection
Post by: vharcourt on 20 Jan 2018 03:47:18 PM
I'm working on generating a list of addresses. Each person can have their name in several different formats (Examples: Joe Smith, Mr. Joe Smith, Joe and Jane Smith). Each format has a naming code associated to it. Right now my report pulls in each name code and their address for each name code. What I would like to do is have the report only display one name code. I have tried If then else statements and a case statements but the results are the same (list all codes and repeated address for that person). I want it to find the first code thats true then not list any of the other codes.

Here is an example of my if then I was trying to use. So basically if it finds the 'LMWDLN' code then the rest shouldn't be displayed.

IF (([Names].[Name Code]) in ('LMWDLN'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('MRIN'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('MRFT'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('SGIS'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('MRIN'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('MRFL'))
THEN ([Names].[Name Description])
ELSE
IF (([Names].[Name Code]) = ('DISP'))
THEN ([Names].[Name Description])
ELSE null
Title: Re: Name Selection
Post by: Stepharia on 23 Jan 2018 05:31:56 PM
Seems like what you want to do is create a data item to manually rank the name codes and then filter for the minimum rank.
e.g. Create a data item called [rank] with each possibility ranked numerically:
CASE  [Names].[Name Code]
WHEN ('LMWDLN')
THEN (1)
WHEN ('MRIN')
THEN (2)
WHEN ('MRFT')
THEN (3)
END
Then add a data filter:
[rank] = minimum([rank] for [address])

That should filter your report to the lowest ranking name code that exists for each address.