<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Best Practices Re: a Calendar Table and Multiple Date Fields in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263216#M707757</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can make arbitrarily-complicated logic to recognize your date fields, probably up to and including regular expressions, though I'd have to refresh my memory on how that is done.&amp;nbsp; This was just an example, and an example that assumed your naming convention for date fields was '* Date'.&amp;nbsp; If it's '* date', then use ' date' where I used ' Date'.&amp;nbsp; Alternatively, just use a "for each in" loop, and specify the date fields you want to build calendars for.&amp;nbsp; The example was trying to go all the way, where merely adding a date field to some QVD the program knows nothing about would result in a calendar being loaded for that date field.&amp;nbsp; But following your earlier argument, you have control over the QVDs, so when you add a date field, you can know to put it in the list.&amp;nbsp; A combination might also work, where anything following the standard pattern would be picked up automatically, while anything that didn't could be placed in an explicit list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as which of the two main approaches is more popular, I don't see how popularity has anything to do with it because they aren't two ways of solving the same problem.&amp;nbsp; They're solutions to two DIFFERENT problems.&amp;nbsp; Your users' requirements should determine which approach you use, or if you use both at once.&amp;nbsp; So let's say you have an application that displays order data.&amp;nbsp; This system has two dates, an order date and a ship date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do your users want to be able to select December 1, 2011, and see all orders placed OR shipped on that date?&amp;nbsp; Then create a single generic calendar linked by date type.&lt;/LI&gt;&lt;LI&gt;Do your users want to be able to see orders that were both placed on November 15, 2011 and then shipped on November 20, 2011?&amp;nbsp; Then create separate calendars.&lt;/LI&gt;&lt;LI&gt;Do your users want to be able to do either of these things?&amp;nbsp; Then create separate calendars AND a generic calendar.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to guess that the separate calendars are more popular in the community &lt;STRONG&gt;&lt;EM&gt;by far&lt;/EM&gt;&lt;/STRONG&gt;.&amp;nbsp; I'm also going to guess that this has little to do with user requirements, and more to do with it being more easily understood by more developers, so that's just what they do.&amp;nbsp; If users ask for the other requirement, I expect many developers to get confused, or even say "QlikView can't do that", and leave it at that.&amp;nbsp; In my own applications, I suspect that it's around a 50/50 mix, and I think I only have one application with both approaches at the same time, and even there, one approach (generic calendar) is primary and obvious, and the other is secondary and somewhat hidden, supplied only for a single power user.&amp;nbsp; We've been using QlikView for 6 years using both approaches, and I don't think there have been any gotchas with either.&amp;nbsp; I'm sure there has been SOME confusion with both approaches, but none that ever made it back to me (and I get a lot of phone calls and emails from users).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: One of my applications has the generic calendar approach but can still answer the kind of questions that separate calendars answer.&amp;nbsp; It does this through an "add to memory" button.&amp;nbsp; So for the example you'd select the "order" date type, and select November 15, 2011.&amp;nbsp; Then hit "add to memory", and what it does is select all of the possible order IDs.&amp;nbsp; Then select the "shipped" date type, and select November 20, 2011.&amp;nbsp; Now you have the same orders as you would have had with separate calendars.&amp;nbsp; A user could of course do this manually without a button.&amp;nbsp; But either way, if your users really want to do that, I'd just provide separate calendars, since that makes it easier for them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, I don't mean to monopolize the replies when you're surely trying to get more of a community perspective instead of my personal perspective.&amp;nbsp; I should probably stop answering and give other people a chance to provide their own opinions.&amp;nbsp; And maybe people will be more likely to do that if I make it obvious like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;EM&gt;&lt;STRONG&gt;What are other people's thoughts?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Dec 2011 20:46:09 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2011-12-01T20:46:09Z</dc:date>
    <item>
      <title>Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263209#M707750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Howdy.&amp;nbsp; I've searched through the forum, but not found a post which quite addresses this question.&amp;nbsp; &lt;A _jive_internal="true" href="https://community.qlik.com/message/95723#95723"&gt;This one&lt;/A&gt; was close, but represented the opposite problem.&amp;nbsp; The "similar posts" tool found more results han my searching: &lt;A _jive_internal="true" href="https://community.qlik.com/message/77624#77624"&gt;this post&lt;/A&gt;, &lt;A _jive_internal="true" href="https://community.qlik.com/message/90094#90094"&gt;this one&lt;/A&gt;, and &lt;A _jive_internal="true" href="https://community.qlik.com/message/30971#30971"&gt;this one&lt;/A&gt; cover some solutions, but don't discuss which is best, or more generally what advantages and disadvantages exist.&amp;nbsp; What's easiest?&amp;nbsp; What's most commonly used?&amp;nbsp; Has anyone used one of these solutions for 12 months or so and has some feedback on how well it's worked?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A common practice in data warehouses is to have a Dates table which gives values such as year, quarter, and month for each day.&amp;nbsp; It looks like this is common in QlikView too, and the name "calendar table" seems to be widely-used.&amp;nbsp; If this calendar table has a Date field as its key, any queries which also contain a Date field will automagically join to it.&amp;nbsp; Groovy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But... what do you do when you have multiple fact tables, with different date fields, which should &lt;EM&gt;not&lt;/EM&gt; join together?&amp;nbsp; For example, say there's a Customers.Date field representing the date the customer was created, and an Orders.Date field representing the date an order was placed.&amp;nbsp; A report which contains both fields will need to rename at least one of them, breaking the join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, a fact table may contain multiple date dimensions.&amp;nbsp; In my case, the Orders table has OrderDate, DatePaid, and ShipDate fields.&amp;nbsp; I could create three more calendar tables, with key fields of OrderDate, DatePaid, and ShipDate, respectively.&amp;nbsp; This seems cumbersome; is this the best practice, or is there a simpler option?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SQL, I'd write three JOINs, to the same table each time but specifying a different field from the first table each time.&amp;nbsp; But QlikView seems to be restricted to natural joins, which as a DBA makes me wince.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using one or more calendar tables, you could just import the date values as dates, and use QlikView date functions to populate your date hierarchies.&amp;nbsp; Is this what most users end up using?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate any input.&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 00:13:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263209#M707750</guid>
      <dc:creator />
      <dc:date>2011-11-29T00:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263210#M707751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your third link above covers the two basic options - create a separate calendar for each field, or create a new table that links dates by date type to a single calendar.&amp;nbsp; It also discusses the advantages and disadvantages of each approach, though mostly in "how the users will interact with it" terms, which in my opinion is primary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, it sounds like you want to keep all these dates separate.&amp;nbsp; You would never want to select November 28, 2011 in a single Date field, and see orders that were ordered, paid OR shipped on that date.&amp;nbsp; If you want to see orders ordered on that date, you would explicitly select that OrderDate.&amp;nbsp; That's option 1 in the third linked thread, which is also the easiest and clearest for most developers, I'd guess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do consider a separate calendar table for each distinct kind of date to be the best practice when you want your dates to be distinct.&amp;nbsp; However, there's no real disadvantage to handling it with SQL-like joins.&amp;nbsp; Denormalization isn't really a problem in QlikView, and any extra memory it might have required will be recovered by compression.&amp;nbsp; If anything, the user interface may actually work marginally faster.&amp;nbsp; We tend to not do this, though, perhaps because the script may be a little slower, or maybe just because everyone else seems to do it with a separate calendar, so that's just what everyone learns, even if there's no real reason for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I've personally done, though I'm not sure that this is common, is create a Calendar.qvd.&amp;nbsp; This helps me enforce standards and centralizes logic if we, say, decide to change our definition of week numbers.&amp;nbsp; If you wished, your example could work with a resident calendar, or you could generate a new calendar for every field.&amp;nbsp; Anyway, the script for the SQL-like join approach would be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (Orders)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Date as OrderDate&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,Month as OrderMonth&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,Year as OrderYear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;FROM Calendar.qvd (QVD)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN (Orders)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Date as DatePaid&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,Month as MonthPaid&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,Year as YearPaid&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;FROM Calendar.qvd (QVD)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And so on for every date field in every table.&amp;nbsp; I can't think of anything wrong with that if you prefer the explicit joins instead of QlikView's association.&amp;nbsp; I suspect it is more common to have separate tables, but there's really no need.&amp;nbsp; The same is true even if you just have a single date field - it may be most common for us to create a calendar table, but it isn't necessary, and there's no real reason NOT to just join the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 00:40:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263210#M707751</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-11-29T00:40:37Z</dc:date>
    </item>
    <item>
      <title>Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263211#M707752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct; I'd like users to be able to filter on each date field separate.&amp;nbsp; Orders placed in September, paid in October, and cancelled in November, for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a Dates QVD, so your rename-and-join method works, which would save me from over-normalizing my fact tables.&amp;nbsp; What makes me hesitate it that I'd have to write dozens of lines of aliases, one for each of the 22 fields in the date table x the number of date fields in my fact table.&amp;nbsp; That's well over 100 lines, to be repeated in almost all reports.&amp;nbsp; Thousands of lines of code, just to &lt;EM&gt;stop&lt;/EM&gt; the system from joining!&amp;nbsp; And if someday a date field is renamed or deleted, I'd need to change the script for every report, making one change for each date field, so several hundred manual changes.&amp;nbsp; This wouldn't be so bad if one could edit QlikView scripts as plain text, separately from the associated reports.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One could save typing by QUALIFYing each copy of the dates table, but then the fields would have ugly names like "Order Date.Is year-to-date".&amp;nbsp; Since field names are the primary interface for non-technical users, I'd like to keep them "pretty".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using multiple QVDs, one for each date field in the warehouse, would still require hundreds of aliases, but at least I would not have to repeat them in each report.&amp;nbsp; It bugs me to store the same data a dozen times over, though it's a small table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These all seem like hacks, painful to build and fragile in use.&amp;nbsp; Are there other approaches?&amp;nbsp; Is there's no way to specify the field(s) by which tables are to be joined, other than aliasing every field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 22:01:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263211#M707752</guid>
      <dc:creator />
      <dc:date>2011-11-29T22:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263212#M707753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems a fundamental limitation of what you want your users to see, not a QlikView limitation.&amp;nbsp; Note that if you were doing this purely with SQL, you can join any way you want, but if you want your users to see a field DatePaid, either you have a table with DatePaid on it, or somewhere in your SQL you're going to see Date as DatePaid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as a better way to do all that aliasing, I'm running off to a meeting, but I think you could use qualify initially, then use a loop through the fields, renaming them according to your pattern.&amp;nbsp; I'm sure we could come in well under 100 lines if you were doing a load *.&amp;nbsp; Though I'd personally avoid load * because it opens you up to unintended associations if people add new fields to the calendar QVD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Nov 2011 22:28:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263212#M707753</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-11-29T22:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263213#M707754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, the big difference in SQL is that I'd only put aliases on the fields I'm using, so three or four per report, not dozens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hmm, so one can rename specific fields after the load?&amp;nbsp; That would be something, I could live with ugly "Order Date"."Is year-to-date" fields if it meant I just needed to alias a few fields in each report.&amp;nbsp; Something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Orders:&lt;/P&gt;&lt;P&gt;LOAD * FROM Orders.qvd (QVD);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OrderDate:&lt;/P&gt;&lt;P&gt;QUALIFY *;&lt;/P&gt;&lt;P&gt;ALIAS OrderDate.%DateKey AS %OrderDateKey;&lt;/P&gt;&lt;P&gt;LOAD * FROM Dates.qvd (QVD);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a bit ugly (the resulting QVW, that is; the script is nice and consise), but it works.&amp;nbsp; I am torn as to whether to accept this or to create the dozen separate QVDs after all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 00:27:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263213#M707754</guid>
      <dc:creator />
      <dc:date>2011-11-30T00:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263214#M707755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So only rename the fields you're using.&amp;nbsp; Why would you load and force yourself to rename fields you don't need?&amp;nbsp; As I suggested earlier, LOAD * FROM Dates.qvd (QVD); is a dangerous practice that leaves you open to unintended associations as people add new fields to the QVD.&amp;nbsp; It also wastes memory to load fields you don't need.&amp;nbsp; Same for ANY load, really.&amp;nbsp; Avoid LOAD * except from something like an inline table where you have full and obvious control over what's being loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following up on what I mentioned in my previous post, I've come up with the attached example that automatically creates calendars associated with every date field in every table.&amp;nbsp; Again, I wouldn't do the load * like in this example, but you could.&amp;nbsp; I suspect it also has a bug if you have the same date field in two different tables already, as it will probably try to load the same calendar and field names twice.&amp;nbsp; I'm sure it's a solvable problem, but I wouldn't actually use this code anyway, so it's just an example of what's possible.&amp;nbsp; As an example, I think it's good enough.&amp;nbsp; In practice, what I do is load the specific fields I need, no more, no less, and rename as appropriate in the load.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: I suspect the script can be simplified.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 01:22:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263214#M707755</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-11-30T01:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263215#M707756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's necessary to rename all the fields for two reasons.&amp;nbsp; Because I'm producing raw data which other people may use, I can't be sure about which fields they may want.&amp;nbsp; Also, if I leave any field names as-is, QlikView will join my date tables together (sigh).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm OK with "LOAD *" (flashback to the Commodore 64 magazine), because I have control over the QVDs and the SQL views from which they get their data.&amp;nbsp; No one else will be changing these files.&amp;nbsp; Plus it's tedious typing every field thrice over (once in the SQL field list, and twice in the LOAD list).&amp;nbsp; The QVDs need all fields, per se; they must store everything so that actual QVWs have access to everything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the sample file.&amp;nbsp; So if I used lower-case names in the Dates.qvd file, and "Order date" as the field name in the orders table, I'd end up with "Order date year", "Order date month", "Order date is business day", "Order date is year-to-date", etc.&amp;nbsp; Nice!&amp;nbsp; That's a little prettier than QUALIFY, which gives me "Order date.Year", "Order date.Month", etc.&amp;nbsp; The downside is 20 lines of code which would need to appear in every script, but there should be no reason for the script to change if, say, we add or rename a field, so that's probably not a time bomb.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still curious about what other approaches people have used, and among the two talked about in this thread and the linked threads, which is more popular and why.&amp;nbsp; Are there long-term gotchas with either approach?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 19:59:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263215#M707756</guid>
      <dc:creator />
      <dc:date>2011-12-01T19:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263216#M707757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can make arbitrarily-complicated logic to recognize your date fields, probably up to and including regular expressions, though I'd have to refresh my memory on how that is done.&amp;nbsp; This was just an example, and an example that assumed your naming convention for date fields was '* Date'.&amp;nbsp; If it's '* date', then use ' date' where I used ' Date'.&amp;nbsp; Alternatively, just use a "for each in" loop, and specify the date fields you want to build calendars for.&amp;nbsp; The example was trying to go all the way, where merely adding a date field to some QVD the program knows nothing about would result in a calendar being loaded for that date field.&amp;nbsp; But following your earlier argument, you have control over the QVDs, so when you add a date field, you can know to put it in the list.&amp;nbsp; A combination might also work, where anything following the standard pattern would be picked up automatically, while anything that didn't could be placed in an explicit list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as which of the two main approaches is more popular, I don't see how popularity has anything to do with it because they aren't two ways of solving the same problem.&amp;nbsp; They're solutions to two DIFFERENT problems.&amp;nbsp; Your users' requirements should determine which approach you use, or if you use both at once.&amp;nbsp; So let's say you have an application that displays order data.&amp;nbsp; This system has two dates, an order date and a ship date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do your users want to be able to select December 1, 2011, and see all orders placed OR shipped on that date?&amp;nbsp; Then create a single generic calendar linked by date type.&lt;/LI&gt;&lt;LI&gt;Do your users want to be able to see orders that were both placed on November 15, 2011 and then shipped on November 20, 2011?&amp;nbsp; Then create separate calendars.&lt;/LI&gt;&lt;LI&gt;Do your users want to be able to do either of these things?&amp;nbsp; Then create separate calendars AND a generic calendar.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to guess that the separate calendars are more popular in the community &lt;STRONG&gt;&lt;EM&gt;by far&lt;/EM&gt;&lt;/STRONG&gt;.&amp;nbsp; I'm also going to guess that this has little to do with user requirements, and more to do with it being more easily understood by more developers, so that's just what they do.&amp;nbsp; If users ask for the other requirement, I expect many developers to get confused, or even say "QlikView can't do that", and leave it at that.&amp;nbsp; In my own applications, I suspect that it's around a 50/50 mix, and I think I only have one application with both approaches at the same time, and even there, one approach (generic calendar) is primary and obvious, and the other is secondary and somewhat hidden, supplied only for a single power user.&amp;nbsp; We've been using QlikView for 6 years using both approaches, and I don't think there have been any gotchas with either.&amp;nbsp; I'm sure there has been SOME confusion with both approaches, but none that ever made it back to me (and I get a lot of phone calls and emails from users).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: One of my applications has the generic calendar approach but can still answer the kind of questions that separate calendars answer.&amp;nbsp; It does this through an "add to memory" button.&amp;nbsp; So for the example you'd select the "order" date type, and select November 15, 2011.&amp;nbsp; Then hit "add to memory", and what it does is select all of the possible order IDs.&amp;nbsp; Then select the "shipped" date type, and select November 20, 2011.&amp;nbsp; Now you have the same orders as you would have had with separate calendars.&amp;nbsp; A user could of course do this manually without a button.&amp;nbsp; But either way, if your users really want to do that, I'd just provide separate calendars, since that makes it easier for them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, I don't mean to monopolize the replies when you're surely trying to get more of a community perspective instead of my personal perspective.&amp;nbsp; I should probably stop answering and give other people a chance to provide their own opinions.&amp;nbsp; And maybe people will be more likely to do that if I make it obvious like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;EM&gt;&lt;STRONG&gt;What are other people's thoughts?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 20:46:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263216#M707757</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-01T20:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263217#M707758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure; I made a few tweaks to your code, mostly to clarify what was happening, but that's just detail.&amp;nbsp; This is exactly what I needed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should have been more clear: the two approaches I was contrasting were (A) multiple date files or (B) joining to the same date file multiple times, using some mechanism to rename its fields for each join.&amp;nbsp; I see how the former approach, which does not require any scripting, would appeal to most users.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Certainly what's most popular shouldn't be the only factor, or even primary, but if most people are doing one thing, it deserves consideration.&amp;nbsp; We've examined this from a couple of angles over the past few days, but there may be more approaches we haven't considered.&amp;nbsp; Though if there is such an animal, given six years with QlikView and 4,500 forum posts, you probably would've seen it by now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 23:26:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263217#M707758</guid>
      <dc:creator />
      <dc:date>2011-12-01T23:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263218#M707759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think in your situation, with a whole lot of different date fields, and wanting all the calendar information for each, I'd left join all the calendar data back onto the main QVD multiple times.&amp;nbsp; I wouldn't want a separate calendar QVD for each date field - that's a lot of joins in the user application.&amp;nbsp; And I wouldn't want a single calendar QVD, because that's just as many joins PLUS a bunch of renames.&amp;nbsp; So I'm thinking you modify the loop to do the joins when you're creating the main QVD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't thought about it long and hard, but that's certainly my initial impulse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact, it has me wondering if I should do something like that around here.&amp;nbsp; We DO have a lot of dates on the order item, but don't tend to use more than one or two in any given user application.&amp;nbsp; That tends to make the load from a generic calendar QVD pretty simple, and I didn't want to inflate the size of my QVDs, so the choice seemed clear at the time.&amp;nbsp; But maybe we shouldn't be doing the generic calendar load at all.&amp;nbsp; Maybe all the date fields should have all calendar fields associated with them by default in the order item QVD.&amp;nbsp; Maybe I've been doing it the "wrong" way all along.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hmmm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Oh, and I'd guess that &lt;EM&gt;neither &lt;/EM&gt;of your approaches is the most popular.&amp;nbsp; I'd guess that the most popular approach is to just add additional fields in the user application during the QVD load, simple month(Date) as Month types of things, deoptimizing the load, or as a left join by key with probably similar performance penalties.&amp;nbsp; I'd bet that the second most popular approach would be to generate calendar tables after the main load in the user application, which can have high performance if done with fieldvalue().&amp;nbsp; A calendar QVD is probably at least third on the list.&amp;nbsp; Multiple calendar QVDs or building everything into the main QVD I'm guessing are rather rare.&amp;nbsp; So I'm thinking the best approach for you is probably one of the most rare things to see people actually do.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 00:04:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263218#M707759</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-02T00:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263219#M707760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I'm following you.&amp;nbsp; If we're agreed that multiple Date.qvd files is not optimal for this scenario, then it follows that we'll have just one, right?&amp;nbsp; Are you suggesting that there be multiple QVDs, generated automatically with the various prefixes?&amp;nbsp; That would eliminate the need to have code for auto-generating Dates tables in QVW files, but would instead entail multiple joins, once for each date field used in the QVW.&amp;nbsp; My Dates.qvd file is 146 KB, for the 7,600-odd days from 2000/01/01 to 2020/12/31, so the space required for multiple files shouldn't have an impact, except for slow connections like VPNs or some home DSLs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or are you suggesting putting all the date fields in each fact table's QVD?&amp;nbsp; That was the approach I started with, but it definitely bloats things to add 20 date fields for each of four date fields in a fact table x 10 million Orders rows.&amp;nbsp; Cutting this out has helped me a lot; my BI server is out-of-state and the bandwidth is not what it could be.&amp;nbsp; So that's a third option, though it entails larger fact tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script-based date table multiplication pattern which your code implements has the advantage of making all date fields available, all the time.&amp;nbsp; And it requires a minimal amount of disk space.&amp;nbsp; I'm having trouble with one line, but I'll post it here when I have it pinned down.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 00:35:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263219#M707760</guid>
      <dc:creator />
      <dc:date>2011-12-02T00:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263220#M707761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right, I was "suggesting putting all the date fields in each fact table's QVD".&amp;nbsp; All fields are then available in one QVD, and the user applications load the ones they need (or load * if you like).&amp;nbsp; I understand your point about QVD bloat, though, and it's certainly one reason I hesitate doing this myself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can nail down the script code, you can include it rather than cutting and pasting.&amp;nbsp; So then user applications would load all their data, and then just have a little include to build all the associated calendars.&amp;nbsp; But then the USER applications have the bloat, because that's almost certainly more fields than they really need.&amp;nbsp; It probably isn't that big a deal in practice, though.&amp;nbsp; How many rows X columns can you have from a few calendar tables?&amp;nbsp; Probably much less data there than your fact tables most of the time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 00:46:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263220#M707761</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-02T00:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263221#M707762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gotcha.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the bloat, I'd argue that it goes the other way.&amp;nbsp; With the multiple-calendar-files approach or the one-file-loaded-multiple-times approach, each QVW loads the whole dates QVD once per date field among the tables loaded.&amp;nbsp; Assuming ten date keys, that's about 1.5 MB: 145 KB for Order Date, 145 KB for Date Paid, 145 KB for Ship Date, etc.&amp;nbsp; I'm using my Dates.qvd file for reference here; it works out to 19 bytes per daily record, 145 KB total / 7,761 days from 2000/01/01 to 2020/12/31.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, putting these date fields in the fact tables' QVDs means adding those 19 bytes once for each date field in the fact table, for each row in the fact table.&amp;nbsp; If our main fact table has six date keys and one million rows, that's 19 bytes x 6 x 1.0E6 = 109 MB.&amp;nbsp; And if we have ten million rows in our fact table, we'll hit the 1 GB mark.&amp;nbsp; I had to give up on this approach when I first took a stab at translating my data warehouse to QlikView, because the load times were just too painful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your calendar file is narrower, this would be less of an issue.&amp;nbsp; However, most of my 22 date fields are Yes/No, which are probably being compressed to bits.&amp;nbsp; So even if you just have the usual suspects like Year, Month, Week, Day, and Day of week, I bet that would use around three-quarters as much space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If load times are the top concern, I guess you'd load a single integer date and use date functions to expand that in the QVW?&amp;nbsp; Your consumers would need to be comfortable with some fairly complex expressions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:00:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263221#M707762</guid>
      <dc:creator />
      <dc:date>2011-12-02T16:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263222#M707763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's things like this that drive me crazy trying to work with QlikView.&amp;nbsp; I've spent hours going over my script, trying to see why it wasn't working, and then today I see &lt;A _jive_internal="true" href="https://community.qlik.com/thread/29455"&gt;a forum post&lt;/A&gt;.&amp;nbsp; It turns out that my script is correct, but there's a bug/undocumented limitation such that you're not allowed to rename a field once it's been used as a key (but you can't force the system to NOT use a field as key!).&amp;nbsp; I'd be OK with this if QlikView gave me a little message "you can't rename keys, bub," but instead it SILENTLY SWALLOWS THE ERROR!&amp;nbsp; No warning!&amp;nbsp; No message!&amp;nbsp; It just ignores the RENAME FIELD command.&amp;nbsp; What sadist thought that was a good idea?!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:38:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263222#M707763</guid>
      <dc:creator />
      <dc:date>2011-12-02T16:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263223#M707764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;JonathanShaltz wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's things like this that drive me crazy trying to work with QlikView.&amp;nbsp; I've spent hours going over my script, trying to see why it wasn't working, and then today I see &lt;A _jive_internal="true" href="https://community.qlik.com/thread/29455"&gt;a forum post&lt;/A&gt;.&amp;nbsp; It turns out that my script is correct, but there's a bug/undocumented limitation such that you're not allowed to rename a field once it's been used as a key (but you can't force the system to NOT use a field as key!).&amp;nbsp; I'd be OK with this if QlikView gave me a little message "you can't rename keys, bub," but instead it SILENTLY SWALLOWS THE ERROR!&amp;nbsp; No warning!&amp;nbsp; No message!&amp;nbsp; It just ignores the RENAME FIELD command.&amp;nbsp; What sadist thought that was a good idea?!&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I entirely agree with you.&amp;nbsp; First, it's ridiculous that we can't rename to a field that already exists.&amp;nbsp; I'm sure they're just trying to protect us from ourselves, but to me, it's an obvious and straightforward way to create associations.&amp;nbsp; Why shouldn't I be able to load a table, manipulate it all I want, and THEN rename a field to create an association?&amp;nbsp; Not allowed.&amp;nbsp; And second, yes, it's even more ridiculous that it returns no error, and simply ignores the rename.&amp;nbsp; QlikView's error reporting sometimes leaves a lot to be desired.&amp;nbsp; Third, I almost guarantee that if you sent this to QlikTech as a bug, they'd say "Working as Designed" and close your ticket with no further action.&amp;nbsp; You would have to submit it as a feature request.&amp;nbsp; I've pretty much stopped reporting bugs after getting that response a few times.&amp;nbsp; I like QlikView and QlikTech in general, but there are definite areas for improvement, areas for improvement that seem rather surprising to me for a mature product and mature company.&lt;/P&gt;&lt;P&gt;Anyway, that's one reason why my script was as tortured as it was - I had to make sure the date field itself got the right name up front rather than fixing it after the fact in the main rename loop.&amp;nbsp; I perhaps should have mentioned that, as fixing that "mistake" seems an obvious thing to do when presented with my script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:53:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263223#M707764</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-02T16:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263224#M707765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm unclear if we're in agreement or not on the bloat.&amp;nbsp; While there are advantages to just putting all the date fields in the main fact table QVD, I agree that adding 100 MB or 1 GB to our main fact table was bloat.&amp;nbsp; That was in the first paragraph.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I meant by user application bloat (second paragraph) was that if we loaded ALL calendar fields for ALL dates in a user application, this was likely to be a lot more fields than the user application needed.&amp;nbsp; User applications would ideally only load fields they need.&amp;nbsp; So whether we use a calendar script, or LOAD * from OrderDateCalendar.qvd (QVD), we'd be causing user application bloat.&amp;nbsp; But also as I said, "It probably isn't that big a deal in practice".&amp;nbsp; As long as they're on separate tables, it won't take much space.&amp;nbsp; It's really only a problem if they're then joined with the main fact table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date are already stored as integers, as the number of days since December 30, 1899.&amp;nbsp; And as long as you have separate calendar tables, they won't take up much space.&amp;nbsp; This is also what you'd do if load times are the top concern.&amp;nbsp; In that case, you wouldn't put all the date fields in the fact table.&amp;nbsp; You'd either have one calendar QVD and rename as you read in, or multiple calendar QVDs.&amp;nbsp; You would not join these to the fact table, but just let the association by field name take care of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now I'm thinking your best answer is to have one calendar QVD, nail down the script code, and use it as an include to automatically generate calendars for every date field in the user application.&amp;nbsp; You get more fields in user applications than you want, but they're on small tables, so it won't affect overall size or performance very much.&amp;nbsp; You get to keep your fact tables as small as possible.&amp;nbsp; Performance, file size, and RAM used should all be pretty good.&amp;nbsp; You maintain your calendar fields in one place.&amp;nbsp; You maintain your calendar script in one place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to look up how to include script, though.&amp;nbsp; I've never done it.&amp;nbsp; Looks like it would be like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;$(Include=GenerateCalendars.qvs)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to fiddle with this a little, because this is starting to sound like something I should consider doing myself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wait... we may be reinventing the wheel, or at least simultaneously inventing the wheel.&amp;nbsp; I bet there's a calendar in Rob Wunderlich's QlikView Components open source project (now in beta).&amp;nbsp; I'm off to have a look...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;A href="http://code.google.com/p/qlikview-components/"&gt;http://code.google.com/p/qlikview-components/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:58:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263224#M707765</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-02T16:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263225#M707766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I'm glad to hear it's not just me.&amp;nbsp; Part of why it's frustrating is that there's so much good stuff in QlikView, if they'd smooth out some of these rough spots (instead of chasing fads with mobile BI, hmm?) they could have such a kick-ass product.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's what worked.&amp;nbsp; I'd thought I could simply rename the key field rather than duplicating it and dropping it, but since that's not possible (or documented!), my code is almost exactly the same as yours, above.&amp;nbsp; I added a lookup table, but mostly I've just commented every other line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;SET HidePrefix = '%';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Orders:&lt;/P&gt;&lt;P&gt;FIRST 100000 LOAD * FROM "Raw Orders.qvd" (qvd);&lt;/P&gt;&lt;BR /&gt;Customers:&lt;P&gt;JOIN FIRST 100000 LOAD * FROM "Raw Customers.qvd" (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DatePrefixes:&lt;/P&gt;&lt;P&gt;LOAD * INLINE&lt;/P&gt;&lt;P&gt;[&lt;/P&gt;&lt;P&gt;%KeyFieldName, %Prefix&lt;/P&gt;&lt;P&gt;%CancellationDateKey, Cancellation&lt;/P&gt;&lt;P&gt;%ConversionDateKey, Conversion&lt;/P&gt;&lt;P&gt;%ExpirationDateKey, Expiration&lt;/P&gt;&lt;P&gt;%OrderDateKey, Order&lt;/P&gt;&lt;P&gt;%DatePaidKey, Paid&lt;/P&gt;&lt;P&gt;%HistoryDateKey, History&lt;/P&gt;&lt;P&gt;%SetUpDateKey, Set up&lt;/P&gt;&lt;P&gt;%ShipDateKey, Shipped&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;FOR _tableNum = 1 TO NoOfTables()&amp;nbsp; // For each table in our file...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _tableName = TableName(_tableNum - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR _fieldNum = 1 TO NoOfFields('$(_tableName)')&amp;nbsp; // For each field in this table...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _dateFieldName = FieldName(_fieldNum, '$(_tableName)');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF WildMatch('$(_dateFieldName)', '%*Date*Key') THEN&amp;nbsp; // This field indicates a date key; import the Dates table, with a prefix to maintain uniqueness&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // The name of the master table's key field determines the human-readable prefix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _prefix = Lookup('%Prefix', '%KeyFieldName', _dateFieldName, 'DatePrefixes');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Load the Dates file, with the key aliased to match the field in the master table to which we're going to join&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _dateTableName = _prefix &amp;amp; ' date';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [$(_dateTableName)]:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD *, "%DateKey" AS "$(_dateFieldName)" FROM "Raw Dates.qvd" (QVD);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Discard the old key field; note that we can't simply rename it, we have to duplicate it and then drop the old field, because QlikView does not permit renaming keys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DROP FIELD "%DateKey";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Rename every field (except the key) in the newly-loaded dates table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR _dateFieldNum = 1 TO NoOfFields('$(_dateTableName)')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _oldDateFieldName = FieldName(_dateFieldNum, '$(_dateTableName)');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF _oldDateFieldName &amp;lt;&amp;gt; _dateFieldName THEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET _newDateFieldName = _prefix &amp;amp; ' ' &amp;amp; _oldDateFieldName;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RENAME FIELD "$(_oldDateFieldName)" TO "$(_newDateFieldName)";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF&amp;nbsp; // If this is not the key&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NEXT&amp;nbsp; // Next date table field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF&amp;nbsp; // If the field name indicates a date key&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NEXT&amp;nbsp; // Next field in the master table&lt;/P&gt;&lt;P&gt;NEXT&amp;nbsp; // Next master table&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wouldn't call it tortured, but yeah now I see why you had what seemed like an odd construct in your original script.&amp;nbsp; Despite this painful detour, your code got me exactly the solution I wanted, so thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:59:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263225#M707766</guid>
      <dc:creator />
      <dc:date>2011-12-02T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263226#M707767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;John Witherspoon wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wait... we may be reinventing the wheel, or at least simultaneously inventing the wheel.&amp;nbsp; I bet there's a calendar in Rob Wunderlich's QlikView Components open source project (now in beta).&amp;nbsp; I'm off to have a look...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;A class="jive-link-external-small" href="http://code.google.com/p/qlikview-components/"&gt;http://code.google.com/p/qlikview-components/&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, Rob's QlikView Components project does indeed include calendar script.&amp;nbsp; You call a script function with a min date, max date, table name, and field prefix.&amp;nbsp; You can establish the min and max date automatically from your data using another call.&amp;nbsp; So I think it looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CALL Qvc.GetFieldValues('vDate','Order Date');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CALL Qvc.Calendar(vDate.Min,vDate.Max,'Order Date Calendar','Order');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then repeat for each date field.&amp;nbsp; And I suspect we could wrap it in our loop that detects date fields in our model if desired.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What seems to be a significant limitation is that it is autogenerating the calendar in the included script, and of course this included script is part of the open source project.&amp;nbsp; It's just a script file, so you can override it to put in all your own field names and definitions, but I think you'd have to store that off somewhere and copy it back in every time you updated the project, while making sure you weren't breaking anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I definitely need to look into it more carefully.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 17:15:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263226#M707767</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-12-02T17:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263227#M707768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed on all that re: bloat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interesting code from Wunderlich.&amp;nbsp; Too bad I didn't find it in my Googling.&amp;nbsp; I've had a hard time finding answers to QlikView questions via plain ol' web search, maybe I'm just not using the right key words.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your syntax is correct for the include command.&amp;nbsp; It gave me some trouble until I discovered that, unlike the SET and LET commands, and unlike what the help file shows, ($Include) will break if you put a space before the equals sign.&amp;nbsp; I suspect it's a conspiracy to make me lose the rest of my hair.&amp;nbsp; But it works, so I'm happy!&amp;nbsp; Now I'll go do something fun, like wrestle a rabid crocodile in a phone booth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 23:02:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263227#M707768</guid>
      <dc:creator />
      <dc:date>2011-12-02T23:02:06Z</dc:date>
    </item>
    <item>
      <title>Best Practices Re: a Calendar Table and Multiple Date Fields</title>
      <link>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263228#M707769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Am I missing something or do we need to do this simply because QV isn't very friendly with the way it handles dates?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;All this for only a drill up drill down?&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;I mean the effort required to create a separate calendar for each date field if you use Rob's script or John's isn't too much, but essentially all you are creating is a series of calendars which allow you to drill up and down date ranges. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Should be easier&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you look at the way Tableau deals with dates, it seems simpler. What happens is that Tableau sees a date field and automatically makes it a drill up and down field. So you drop in a date, say Order Date and then you automatically get Order Day / Week / Month / Qtr / Year. Now if you have different Fiscal years, this might need some tweeking. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Each Calendar could be different&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;I would agree that creating a new calendar for each field may be useful. In the example of Ordered / Shipped / Invoiced, it might be the case that different periods are used for these business processes. This could easily be the case in a large multi-national environment where invoice date conforms to a Fiscal period at head office in the USA and the order date falls into a different period, so you may have the date fields linking to a totally separate calendar table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A final question - do you stick with Set Analysis or Mix it Up?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Let's say I created a document which tracks Orders / Shipped / Invoiced. That lends itself nicely to a central concatenated FACT table as the columns for each process are similar. In this case, we can also use a central DateKey which would correspond to the transaction date for each process.&lt;/P&gt;&lt;P&gt;In this case, you can easily create a few listboxes linking to the central calendar for Year/Month/Day. When a user clicks on a day, you will get all the Orders, Shipments and Invoices for that day. Remember, we did a concatenation and set the DateKey to be the transaction date for each transaction type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, back to John's comment in a previous part of the thread:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;UL&gt;&lt;LI&gt;Do your users want to be able to select December 1, 2011, and see all orders placed OR shipped on that date?&amp;nbsp; Then create a single generic calendar linked by date type.&lt;/LI&gt;&lt;LI&gt;Do your users want to be able to see orders that were both placed on November 15, 2011 and then shipped on November 20, 2011?&amp;nbsp; Then create separate calendars.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The user may be wanting to see all orders for one day , then the corresponding shipments and invoices. Set analysis will work best for that. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Personally, I am leaning towards using set analysis everywhere, but it does make things more complex mainly, I think for the reason that you have to anticipate what the user is going to do much more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 22:49:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Best-Practices-Re-a-Calendar-Table-and-Multiple-Date-Fields/m-p/263228#M707769</guid>
      <dc:creator>johnpaul</dc:creator>
      <dc:date>2012-01-11T22:49:24Z</dc:date>
    </item>
  </channel>
</rss>

