3 Replies Latest reply on May 24, 2016 10:16 AM by Ivan Young

    Display N (1) ROW depending on selected country

    Sanjay Nimbark

      Hi Community,

       

      I am new to Tableau world, We have task to show benchmark data depending on selection by user, our data source is SQL primary data bring all data and secondary data bring only benchmark data,

       

      Challenge : On filter depending on country selected , the Benchmark should show only one line

       

      so for example if user select uk, portugues  > Benchmark area should show Europe

      if user select multiple Region ( country select like uk, portugues, india, Argentina ) then benchmark area should show only World Region (Enterprise Data)

       

      I thought couple of logic but could not get success and getting error while creating calculation field like

       

      IF CountD(country) >=1 and CountD(Region) > 1 then 'World'

      Else (Region)

      End

       

      give me can nt mixed with aggregate with non aggregate etc..

       

      could any one help please.

       

      kind regards,

      Sanjay

        • 1. Re: Display N (1) ROW depending on selected country
          Ivan Young

          Hi Sanjay,

          I think you could accomplish your goal with LOD expressions and context filters.  It sounds like you want to return World if more than one Regions is returned based on filter selections.  Country will always need to be gte 1 in order to return a region so it's not needed in your logic.  Can you confirm this is what you are trying to do?

           

          Thanks,

          Ivan

          • 2. Re: Display N (1) ROW depending on selected country
            Sanjay Nimbark

            Hi Ivan,

             

            Yes you are right country is always greater then 1 in order to achieve this, I  have tried couple of logic but unsuccessful to achieve what I want ,

             

            I have tried

            IF CountD(Region ) >1 then 'World'

            Else Attr([Region])

            End

            This calculation did what I want but it is measure so I cant mixed with or create relationship with other source because of measure instead of dimension

             

            Then I have tried

            IF

            Fixed { [Company] : Countd(Region) } >1 then 'World'

            Else [Region]

             

            This calculation help some sort of but not correct, Think we have multiple company and company have multiple country and region say for example coca-cola, When user select one country it should show that particular region, and if it select multiple country, multiple region then World,

             

            We have report with filter like DATE, Company, Country

             

            could you please help on this

             

            thanks

            • 3. Re: Display N (1) ROW depending on selected country
              Ivan Young

              Hi Sanjay,

              It sounds like you are on the right track, in fact your calculated field is correct.  I think all you need to do is add your filters to context and your solution will work.  I didn't see data for company or date in your example but you'll probably want to add those filters to context as well.  Look at the example tab in the modified workbook and let me know if you have any questions.

               

              Good luck,

              Ivan

              1 of 1 people found this helpful