8 Replies Latest reply: Oct 31, 2016 9:06 AM by Mayank . RSS

    What are flags in QV?

    Deepak Vadithala

      Dear All,

       

      I have encountered few posts on flags. Please can you some explain in detail about flags and where to use them? I am completely ignorant with this concept... I have done some search but could not relate/understand them.

       

      Many thanks in advance.

       

      Cheers - DV

        • What are flags in QV?
          Stefan Wühl

          Hi D V,

           

          well I would describe flags as binary status indicator, it's a mean to signal or mark certain states.

           

          For example, you could mark records with a flag LY and value 1 to indicate that the record's date is within last years date range. If it's not, the value is 0.

           

          You then could count the records by using sum(LY) (and the record set is still selection depending).

          And you also could use the flag to filter records and summing up another field, like

          =sum(LY * Sales)

           

          So a flag is often used putting some maybe complex decisions into the load script to create the flag and using the binary status for fast evaluation in the front end.

           

          Could you give some examples you like to understand?

           

          Hope this helps,

          Stefan

            • What are flags in QV?
              Deepak Vadithala

              Hi Stefan,

               

              Thanks for quick response. Please can you post an example or explain in detail? Sorry, I am not very clear with this concept.

               

              Thanks again.

               

              Cheers - DV

                • Re: What are flags in QV?
                  Stefan Wühl

                  Hi D V,

                   

                  I attached a simple example using flags for Last Year, Last Year to Date, This Year and This Year to Date created in the script.

                   

                  I then use the flags to calculate the sum of values filtered by the Flags (yes, you could also do this using an if() or set analysis) in the front end.

                   

                  Regards,

                  Stefan

                   

                  P.S. The usage of flags is not limited to the mentioned examples, they are just it - examples.

                   

                   

                    • Re: What are flags in QV?
                      Kadir Okan Piroglu

                      Dear swuehl,

                       

                      Thanks for the explanation and sharing a good example. Now I have better understanding of flags.

                       

                      What would be the best expression to always display last 12 months? (I would like to use this as dimension in my charts. i.e. if today is 22nd September 2011, I want my date range to be between 22 September 2010 to 22 September 2011).

                       

                      I will appreciate if you could share your views as I could not address this yet.

                       

                      Best regards,

                       

                      piroglu1907

                       

                      Update: I have used following statement under my FROM field in script editor. Now all the records are applied this criteria. It solved my problem but there could be cases where we may not want to apply it to all dates. I am wondering if there are better solutions for it.

                       

                      Where (created_date)>= AddMonths(Today(),-11);

                        • Re: What are flags in QV?
                          Stefan Wühl

                          Hi piroglu1907,

                           

                          you could also use a flag to indicate the dates within the last 12 Months, add something like

                           

                          ...

                          if(Date <= Today(0) and Date >= AddMonths(Today(0),-12),1,0) as  L12M,

                          ...

                           

                          to the calendar in the script.

                           

                          To create a chart that shows only the data for dates within the last 12 months,

                          you just need a chart with dimension Date and expression

                          =sum(Value * L12M)

                           

                          This will return zero for all dates outside the date range, and QV will not show these lines

                          if suppress zero values is checked as option in presentation tab of chart properties.

                           

                          You could also use a calculated dimension like =if(L12M, Date) to limit the dimension,

                          but I believe using the above expression is better performaning (but just try both versions and compare).

                           

                          I have attached an updated sample file with this flag and the chart, too.

                           

                           

                          I also found this blog quite interesting, describing the use of a calendar flag matrix on huge data.

                          http://iqlik.wordpress.com/2011/05/22/a-new-choice-of-armor-the-flag-matrix/

                           

                          Regards,

                          Stefan

                  • Re: What are flags in QV?
                    ankit bisht

                    PFA hope it helps

                    see how i use flag  as transaction type and i have used them in my bar chart