Macro in the Report studio

Could you please correct me

I have to restrict the Salary element( column) in the Report studio report for the HR Group.

If (#sq(CSVIdentityNameList())# contains ‘HR’)
then ([Salary])
else (0)

If I want to restrict the particular employee name is Scott and he is under the group Dept, how will I write the macro in Report studio?

Kindly need this help from your side

  1. When you have a Query Subject selected, in the Properties window edit the Security Filters and assign certain groups certain data. Ex. [Database View].[Query Subject].[Item] = ‘HR Group’

This way requires constant maintenance and publishing/deploying if you add any groups to Cognos.

  1. FIRST: you must have security groups that MATCH the data you are filtering (in your case ‘HR Group’, ‘Dept’, etc.) - see the bottom paragraph if you don’t already have this. When you have a Query Subject selected, right-click, Edit Definition, choose the Filters tab, Add a filter, choosing the same query subject, apply a macro that looks up the user’s group to see if they can get the data you want. Ex. [Database View].[Query Subject].[Item] in (#CSVIdentityNameList()#)

So you’d create a Query Calculation that looks something like this:
CASE [Database View].[Query Subject].[Item]
WHEN 'Salary’
THEN 'HR GROUP’
WHEN 'Dept’
THEN 'Scott’
END