{"id":141,"date":"2019-03-20T21:08:32","date_gmt":"2019-03-21T02:08:32","guid":{"rendered":"http:\/\/qlikwithfriends.com\/?p=141"},"modified":"2019-12-02T02:09:42","modified_gmt":"2019-12-02T07:09:42","slug":"drop-all-unneeded-tables-in-an-app","status":"publish","type":"post","link":"https:\/\/qlikwithfriends.com\/index.php\/2019\/03\/20\/drop-all-unneeded-tables-in-an-app\/","title":{"rendered":"Drop All Unneeded Tables In An App"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"141\" class=\"elementor elementor-141\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f0d64b2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"f0d64b2\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b4be2f2\" data-id=\"b4be2f2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4955de1 elementor-widget elementor-widget-text-editor\" data-id=\"4955de1\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>In this post, I\u2019d like to share a technique for managing tables that I\u2019ve used in both QlikView and Qlik Sense apps. Very often you\u2019ll have an app that contains data that you binary load into one or more apps. Depending upon the number of tables and size of the data, that app can be quite large. Usually, you\u2019ll need all the data in the source app, but what if you only need one table, or just a few?<\/p><p>Here\u2019s a script that enables you to binary load your data and then quickly drop all the tables except the ones you need.<\/p><p>Let\u2019s assume that we have an app containing many tables. We\u2019d like to drop all the tables and keep only tables names States, Customers and Sales. The script below does this. All we need to do is set the variable \u201cvKeepTables\u201d to a string containing the table names we\u2019d like to keep, separated by semi-colons.<\/p><p>Follow the comments to see how it works.<\/p><p>Here\u2019s a script that enables you to binary load your data and then quickly drop all the tables except the ones you need.<\/p><p>Lets assume that we have an app containing many tables. We\u2019d like to drop all the tables and keep only tables names States, Customers and Sales. The script below does this. All we need to do is set the variable \u201cvKeepTables\u201d to a string containing the table names we\u2019d like to keep, separated by semi-colons.<\/p><p>Follow the comments to see how it works.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a180f11 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a180f11\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4275310\" data-id=\"4275310\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2a1ff39 elementor-widget elementor-widget-text-editor\" data-id=\"2a1ff39\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\/\/ First, set the string of table names that we\u2019d like to keep.<br \/>Set vKeepTables = \u2018States;Customers;Sales\u2019;<br \/><br \/>\/\/Next, build a mapping table that contains the table names from the string above.<br \/>KeepTables _Map:<br \/>Mapping Load<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 SubField(&#8216;$( vKeepTables)&#8217;, &#8216;,&#8217;) as KeepTableName,<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 1 as Tresult<br \/>AutoGenerate 1;<br \/><br \/>\/\/ Iterate through all the table names in the app. If the table name is not found in the mapping table<br \/>\/\/ then Drop it.<\/p><p>For vTableNum = NoOfTables() -1 to 0 step -1 ;<br \/>\u00a0\u00a0\u00a0\u00a0 Let vTableName = TableName($(vTableNum)) ;<br \/>\u00a0\u00a0\u00a0\u00a0 If ApplyMap(&#8216; KeepTables _Map &#8216;, &#8216;$(vTableName)&#8217;, 0) = 0 then<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Drop Table &#8216;$(vTableName)&#8217;;<br \/>\u00a0\u00a0\u00a0\u00a0 EndIf;<br \/>Next;<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-de3430a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"de3430a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-590874b\" data-id=\"590874b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-cc8af69 elementor-widget elementor-widget-text-editor\" data-id=\"cc8af69\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>You\u2019re probably wondering why I set a variable to the names of the tables that I\u2019m keeping and then load it into a mapping table, instead of just doing an inline load of that table \u2026 you we\u2019re wondering, weren\u2019t you? The script is written such that is can be stored as an external script and then used via an Include (or better still, a Must Include) statement. That was anyone can use it. All they need to do is set the variable in their app and call the script.<\/p><p>What are your favorite utility scripts? Let me know in the comments. Or let me know what you\u2019d like to know how to do.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>In this post, I\u2019d like to share a technique for managing tables that I\u2019ve used in both QlikView and Qlik Sense apps. Very often you\u2019ll have an app that contains data that you binary load into one or more apps. Depending upon the number of tables and size of the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[6,9],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-qliksense","category-scripting"],"_links":{"self":[{"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":7,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qlikwithfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}