I want to be able to let the business manually enter a USERID into a parameter box or leave it blank for it to bring back all USERID's.
I have setup another parameter for CUSTOMERID which uses a dataset to bring back a list of customer ID's. Due to the amount of USERID's I don't want to use the same solution but instead have them manually enter the USERID or leave it blank and bring back ALL.
SELECT
CUSTOMERID,
CASE
WHEN STATUSCODE = 200 THEN 'Successful Logon'
ELSE 'Unsuccessful Logon'
END as LogonStatus,
COUNT( * ) COUNTOFACCOUNTS
FROM
MA4EQNG.APPLICATIONLOG
WHERE
CUSTOMERID in ('"+join(Parameters!CustomerID.Value, "','")+"')
AND (Cast(DATETIME as Date) >= '"& Format(Parameters!FromDate.Value, "yyyy-MM-dd") & "'
AND Cast(DATETIME as Date) <= '" & Format(Parameters!ToDate.Value, "yyyy-MM-dd") & "')
AND COMPONENTDESCRIPTION = '/eq/auth/v1/logon'
AND METHOD = 'POST'
GROUP BY
CUSTOMERID,
CASE
WHEN STATUSCODE = 200 THEN 'Successful Logon'
ELSE 'Unsuccessful Logon'
END
ORDER BY
CUSTOMERID ASC
Please let me know if you need anything else.
You can set the USERID parameter to allow blank value then use IF condition on your main dataset sql script.
Try
IF LEN(@USERID)>0
*put the sql script with UserId filter in where clause*
ELSE
*put the sql script WITHOUT UserId filter in where clause*
Normally you would just script something like this in the WHERE clause.
WHERE isnull(@CustomerID,'') = '' OR (CUSTOMERID in('"+join(Parameters!CustomerID.Value, "','")+"'))
And long term, I would create a function that takes in a delimited string, and converts them to rows, then you can just join on the results from the table valued function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.