Hi,
I have some strange behaviour in my dashboard related to filtering. Using the standard collection member filters it is possible to select a value of "(none)" by selecting "All" and then deselecting "All". This value should in theory cause the results to be filtered in order to show only those records that have no value for the filtered field (to my mind anyway, please correct me if I'm wrong). As an example, "Department" is an optional field on one of our records. There are records that have Departments selected and there are records that don't. I would assume that selecting "(none)" for the Department field ought to show me only those records with no Department selected (I'd expect the where clause to look something like "where IdDepartment is null").
Unfortunately for me, that isn't what is happening, and instead the dashboard renders completely empty. Every single chart that is connected to the filter in question shows No Data (or would if we weren't hiding the No Data message, I've tested this). There are some charts that should never show the No Data message, because they always return something, even it's a bunch of zeroes. Even they don't show anything. I find this bit particularly odd.
I decided to do some testing and profile my database while I ran the dashboard, to see what SQL was actually being run. The SQL that is run returns rows. It is actually identical to the SQL that is run when the filter is set to All (which is still wrong, but in a different way). So it seems I should be getting data back from the cubes, but I'm not. It looks to me like something is coming along after the data is retrieved and essentially telling the dashboard "don't bother showing any of this." Why that would happen I have no idea.
My question is what does "(none)" in this context actually do? I would expect to be able to deal with it the way I deal with the "All" token, which is to test for it in the bridge parameter script and replace it with "All" as a string in the manual query (making my placeholder $phDepartment$='All', basically), but I can't figure out what to test for. When I test for All, I check that the input value is equal to PredefinedToken.All, but PredefinedToken.NoSelection, which I thought might be the answer, does nothing.
Below, I've pasted the script from one of our Bridge Parameters, and some sample SQL from one of our cubes that shows how we use the value within a query, in case this helps to explain.
CollectionMemberValue memberValue = (CollectionMemberValue)$input$.Resolve(); var commaDelimitedString = string.Empty; //Pass "All" string if user selected "All" checkbox or "All" token if(memberValue.Token != null && memberValue.Token == PredefinedToken.All ) { commaDelimitedString = "All"; } else { for (int i = 0; i < memberValue.Values.Count; i++) { if (commaDelimitedString.Length == 0) { //Need to strip off appended level unique name... see Example 1 commaDelimitedString = memberValue.Values[i].UniqueName.Replace(".A",""); } else { //concatenate all selected values to a comma-delimited string commaDelimitedString = string.Format("{0},{1}",commaDelimitedString, memberValue.Values[i].UniqueName.Replace(".A","")); } } } return new SingleStringValue($id$, commaDelimitedString);
AND ( $phDepartment$ = ‘All’
OR CONVERT (VARCHAR, deptlink.OrganisationalScopeOthersId) IN ( SELECT * FROM dbo.split ($phDepartment$, ‘,’) ))
In this example, the values from the filter are converted to a comma delimited string of Ids, which we then use in our where clause to filter the results. If $phDepartment$ is “All”, which it will be if the All token is selected, we essentially ignore this filter and allow all values through. For the “(none)” case, I would expect the value of $phDepartment$ to be null, or to have some way to make it null, so that the where clause doesn’t pick up anything where the Id is not null. There is a left join in the query that ensures that rows with no departments are returned, so filtering on null is not pointless here.
I’ve rambled a lot, but I’m hoping in that ramble I’ve explained what I’m seeing and what I’d like to be seeing. If anyone can help me figure this out, I’d appreciate it.