4 Replies Latest reply on Nov 24, 2016 9:41 AM by Jordan Ross

    Applying filter to multiple data sources: Cannot use boolean type in 'IF' expression

    Jordan Ross

      Hello All,


      I am working on a very simple dashboard, which will essentially be used only to create scheduled PDF reports. The dashboard consists of 4 charts, 2 from Data Source A, and two from Data Source B. The data sources have many of the same variables, including a region variable.


      Right now, everything works but you need to use two region filters in order for the dashboard to display the same region for all charts. I would like to be able to have a single filter that works for both data sources.



      My approach as been to make a PARAMETER called "Region Filter", with 5 options (Regions 1 through 5). This parameter can then be applied as a filter to all all charts. I then tried to make a CALCULATED FIELD within each data source that has the following code:


      IF [Region Filter] = "REGION 1" THEN [Region] = "REGION 1"

      ELSEIF [Region Filter] = "REGION 2" THEN [Region] = "REGION 2"

      ELSEIF [Region Filter] = "REGION 3" THEN [Region] = "REGION 3"

      ELSEIF [Region Filter] = "REGION 4" THEN [Region] = "REGION 4"

      ELSEIF [Region Filter] = "REGION 5" THEN [Region] = "REGION 5"



      However, I get the following error, "cannot use boolean type in 'IF' expression.


      I have looked up previous threads regarding this error, but most of the time it is people making the filter a selector for different variables, not values within a single variable. My understanding is that the IIF expression won't work here, because I have 5 options instead of 2.


      Any thoughts?