Multiple mask criteria on columns (or equivalent)

DataGraph Forums Technical Support Support Desk Multiple mask criteria on columns (or equivalent)

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10320
    richard brown
    Participant

      I have imported data from Excel that consists of a number of parameter columns and a single result column. I want to plot several combinations of parameters on the same graph, but I’m not sure of the best way to do that. If I could create a masked column with multiple criteria, I would be able to achieve what I want. But it appears that you can only have one criteria per masked column. Is there another way to achieve this? As an example, column 1 is the x axis, column 2 is the y-axis. I then want one line plot of a subset of columns 3 and 4, and a second plot with a subset of columns 3 and 4, each based on a different range of data in 3 and 4. Any advice is appreciated. Thank you.

      #10321
      dgteam
      Moderator

        Hi Richard,

        You are correct the Mask column can only do one criterion at a time.

        Instead you can create expression that evaluate muliple logical criteria. For example, here is a column created to idenify where first is one and second is two.  Then you could mask using the criteria column.  If the columns you are comparing to are text columns, you can use the options in the text column object, to map to numbers.

        criteria

        Note rather than using a mask column, you can add muliptle criteria to masks in commands or command groups.

        criteria2

        Do either of these approaches solve your issue?

         

         

        #10322
        richard brown
        Participant

          How is the source column for the expression column specified?

          #10323
          dgteam
          Moderator

            For Expression columns, you have to type in the name of the columns in the column object entry box.  Here is a simpler example. The first expression is saying ‘First expression = numbers’, and just returns the same values.  The second expression is a logical statement using mathematical operators to check when the values in the column are equal to 4.  These logical statments return a “1” when true.

            criteria3

            Expresssions may break if you move a column into different group or change the name.  You also have to use a path name or a redirect column when the column you want to reference is not in the same location as where you are testing the criteria.

            Hope that helps.

            #10324
            richard brown
            Participant

              So what I am trying to do is use an expression column to get the values of col “A”, using criteria from cols “B” and “C” for example.  In the example below, I am only getting the expected value in row 1. In row 3, I would expect to get 137704 but instead I get the row 1 value. Also, I would want the rows that don’t match the criteria to be empty, not “Bad index”.  I suspect my syntax A (B == 250000 && C == 1) is incorrect.

              Thanks.

              Screenshot 2023-02-07 at 2.48.43 PM

              #10326
              dgteam
              Moderator

                You’re very close!  The statement expression B == 250000 && C == 1 is correct.   It returns a value of 1 when the expression is true.  That means you have A(1) or A(0).  A(1) returns the first row in column A and there are no zero indexes allowed, which is why you get a bad index.

                Instead, try wrapping this in an if statement.  It will return the first value when true and the second when false.

                if(B==1 && C==1, A(#), nan)

                The column variable ‘#’ is the way to refer to the row number. Here is an example:

                citeria1

                You can also use:

                if(B==1 && C==1, A, nan)

                This does the same thing but you don’t have to explicitly show the row index.

                There is no way to return an empty value using an expression, so instead you use ‘nan’ (not a number).  Most of the drawing commands just ignore ‘nan’ values, so you can still graph columns that contain ‘nan’.

                If you want to remove the nan values, you can do that with a Mask column. Or you can do the check in one step and use a Mask column to return A based on that column, as shown here.

                citeria2

                 

                #10327
                richard brown
                Participant

                  Thank you, that’s exactly what I need. I appreciate the timely answers!

                Viewing 7 posts - 1 through 7 (of 7 total)
                • You must be logged in to reply to this topic.

                DataGraph Forums Technical Support Support Desk Multiple mask criteria on columns (or equivalent)