Adding some time to dates with ‘if’ conditions

DataGraph Forums Technical Support Support Desk Adding some time to dates with ‘if’ conditions

Tagged: 

  • This topic has 4 replies, 3 voices, and was last updated 8 months ago by petercreate.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13629
    petercreate
    Participant

      Hi,

      Just would like to get a new column with conditions. Saying if it is under the “A” condition, I want to get date + some seconds in the second column if the third column in condition “A” and get date + some other time if in “B”, as shown in the picture below. What should I type in the command blank?

      Screenshot 2024-03-25 at 11.58.52

      #13634
      Jean-Yves Le Stang
      Participant

        Hi,

        The test of “if ” function can only apply to a number column while the “Selection” column is a text.

        Suggest you generate a mapping “text to number” column For each value of the Selection column as shown below: Asel is 1 if Selection value is A and 0 if Selection value is B. Swap the mapping allocation for the Bsel column and create the function DateAndTime as follows:

        DateAndTime = Date+(ASel* SliderTimeA)+(BSel* SliderTimeB)

        If in the formula above you replace “BSel” by “1-ASel” you can spare the generation of the BSel column.

        Column mapping menu can be found in the drop down menu of the Column Section.

        Note that in DG the time unit is seconds (86400 sec in one day) and that the time slider values are in seconds in the Variable section.

        I hope it helps.

        Schéma

        #13638
        dgteam
        Moderator

          @le-stang  – A very elegant solution!

          FYI – There are also some mapping options within the Text column itself to map text to numbers, that were there before we had the Map column. Expand the column object for a text column and you will see the options. This could mean fewer columns to create, but we do think there’s a benefit to using the map column because it’s more transparent about what is going on.

          #13640
          Jean-Yves Le Stang
          Participant

            Even more elegant ! The funny thing is that I used this mapping possibility a few days ago for another case. Getting older and older…

            Many thanks

            #13659
            petercreate
            Participant

              @all, thanks to you all. I tried both, working perfectly. I didn’t know If function didn’t work for text. My previous workaround is making it in Excel, the silly way. Now the wrangling can be done in DG on my side. Thanks, again.

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

            DataGraph Forums Technical Support Support Desk Adding some time to dates with ‘if’ conditions