1 Reply Latest reply: Sep 23, 2016 2:39 PM by Michael Tarallo RSS

    Variables in Join

    Christopher Ellis

      Could anyone explain the syntax to replace a table name with a variable after the join statement.

       

      A="Table1"

       

      Sub One(A)

          Join (A)

             Load *

          Resident Table2;

      End Sub

       

      Call One(A)

       

      Many Thanks

       

      Chris

        • Re: Variables in Join
          Michael Tarallo

          Hello Christopher,

           

          SET vFileName = smart_orders.xls;
          
          [Orders$]:
          LOAD
              [OrderID] AS [OrderID],
              [OrderDate] AS [OrderDate],
              [CustomerID] AS [CustomerID-CustomerNumber],
              [EmployeeID] AS [EmployeeID],
              [ShipperID] AS [ShipperID],
              [ProductID] AS [ProductID],
              [Sales] AS [Sales],
              [COS] AS [COS],
              [GP] AS [GP],
              [Quantity] AS [Quantity],
              [Discount] AS [Discount],
              [Freight] AS [Freight],
              [StatusID] AS [StatusID];
          LOAD [OrderID],
              [OrderDate],
              [CustomerID],
              [EmployeeID],
              [ShipperID],
              [ProductID],
              [Sales],
              [COS],
              [GP],
              [Quantity],
              [Discount],
              [Freight],
              [StatusID]
          FROM [lib://AttachedFiles/$(vFileName)]
          (biff, embedded labels, table is Orders$);
          

           

          Not the variable declaration: SET vFileName = smart_orders.xls;

          And the usage: $(vFileName)

           

          You do not always need to include quotes with variables: as both will work in this case:

           

          SET vFileName = "smart_orders.xls";

           

          Or

           

          SET vFileName = smart_orders.xls;

           

          Here is a good article about using quotes written by one of our resident experts:

          https://www.scribd.com/doc/229761684/Single-vs-Double-Quotes-Qlikview-How-and-When-to-Use

           

          Let me know how you do.

           

          Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.

           

          Regards,

          Mike Tarallo

          Qlik