We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

If no results in Node 2, output results from Node 1

Comments

6 comments

  • Avatar
    Adrian Williams

    This scenario is similar to the situation that was discussed in this post. It's not the same but the logic can be adapted to select dataset A if it contains records or dataset B if there were zero records in dataset A.

    A dummy record is concatenated with the data from dataset A (your Node 2) so that there is always at least one record in the dataset, with the dummy record always being the first (or only) record in the dataset.

    A record count field and a dataset ID field are added to dataset A. The record count is zero indexed (meaning the dummy record will have a record count of 0). The dummy data field is removed from dataset A.

    The data in the alternative dataset (your Node 1) is modified to also have the record count field and the dataset ID. In this case the record count is fixed at -1 and the dataset ID is set to "B". Note that the metadata for the two data sets is now identical.

    The two data sets are then concatenated, with the records from dataset A being the first records output from the Cat node.

    A transform node is then used to determine which data set to output. The first record is discarded as this will always be the dummy record. Then for subsequent records, the node examines the value of the record count field. If the record count is greater than zero then there was at least one 'real' record in dataset A so the node is configured to output the records from that dataset.If there were no 'real' records in dataset A then the node remains configured to output records from dataset B.

    Note: Data360 Analyze 3.6.0 or above is needed to import the example data flow.

     

     

    Attached files

    Output_Alternative_Dataset_If_Zero_Records - 7 Apr 2020.lna

     

    0
    Comment actions Permalink
  • Avatar
    Geoff

    I have come up with another way! seems to work fine. By adding a boolean field to each dataset (Node1,Node2) and setting one to false, the other to true, You can output Node 1 or 2 depending on if it has data

    Basically the bottom nodes, output just the bool field, then reduce it to 1 or 2 rows (1 row if only the bottom data has data), 2 rows if both have data... then sort and grab the top row.. if false, then the top data has data, true if only the bottom data has it...

    I know, its odd but it works... 

    a cat node with ifs would be cool.. hint hint.. 

     

    I put it into a Composite so you can just copy it and drop it in...

     

    Attached files

    Zero-NonZero - 7 Apr 2020.lna

     

    0
    Comment actions Permalink
  • Avatar
    Brad Brezinski

    Hello Adrian or Geoff,

    We installed recommended Data3Sixty version less than 6 months ago. We are running version 3.4.3. Is there a way you can export data flow examples compatible with earlier versions?

    Thanks for any thoughts,

    Brad

    0
    Comment actions Permalink
  • Avatar
    Geoff

    I created it in Lavastorm, you should be able to just import this...

    Then copy the nodes out into your flow

     

    Attached files

    zero nozero.brg

     

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    Hi Brad,

    apologies, here is a version that should import into any 3.4.x instance.

    Unfortunately, due to the changes in the underlying model for the data flow between the 3.6.x release series and the 3.4.x release series it's not possible to export from a later LTS release series to an earlier LTS release series - you can only export and import within the same LTS release series.

     

    Regards,

    Adrian

     

    Attached files

    Output_Alternative_Data_Set_If_Zero_Records_342 - 9 Apr 2020.lna

     

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    Just to clarify the example, the logic in the blue box in the screenshot below just replicates whatever logic is being used to create the two data sets (of which one may have zero records). I used the Filter node in the red box to either allow records to be produced or to create zero records, so the logic on the right of the data flow could be tested.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.