1 Reply Latest reply: Oct 8, 2018 9:09 AM by Felip Drechsler RSS

    How to compare string type variable values through if statement

    bhawna Agrawal

      Hi All,

       

      Below is my current bar chart. I have a requirement that instead of 4 type of user types coming from database this chart have only 2 types of user type. From DB we will have 4 user type data but in chart it shows only 2 i,e, employee and contractor. If user type is either employee or intern then they both combine to employee and if usertpe is contractor or customer then they both combine and show as contractor. Below is the script i am using to load data and tied with if statement(currently commented) bit didn't worked.

       

      userType chart.png

       

      script.png

        • Re: How to compare string type variable values through if statement
          Felip Drechsler

          Hi,

           

          I'd say your in the right track, but instead of using the AND clause on your commented code, use OR.

          if (usr_emp_type = 'Employee' OR usr_emp_type = 'Intern','Employee','Contractor') as [Nem Dimension]


          So for each usr_emp_type, you'll have either 'Employee' or 'Contractor'.


          Another way to do it is like so:

          if (usr_emp_type = 'Employee' OR usr_emp_type = 'Intern',1,0) as [Employee Count],

          if (usr_emp_type = 'Contractor' OR usr_emp_type = 'Customer',1,0) as [Contractor Count]


          So on your charts, you can sum the created counters above.