4 Replies Latest reply: Mar 2, 2016 2:15 AM by Agathe Fischer RSS

    How to change the Standard format and once update the charts

    Agathe Fischer

      Hi all,

       

      We want to use the same qvw-file for multiple users. And each has his own Format. So I have to change the Standard formats.

       

       

       

      SET ThousandSep='.';
      SET DecimalSep=',';
      SET MoneyThousandSep='.';

      .

      .

      .

      (The new Information is coming from the database and it works (such like LET DecimalSep=peek('GlobalDecimalSymbol',0,SystemSetting);

      ))

       

       

      Now there is the problem, that changing the Format to an existing file,

      the Charts are not updated.

      They only are updated if you change the Settings, deactivate the Format and activate it again, and this you have to do for each Chart.

       

      Someone had the same problem in this thread:

      Number Format Setting Separators,  Decimal and Thousand not defaulting to values from ThousandSep and DecimalSep.

       

      The solution was to write a makro.  Does anyone have another idea? Does this makro really do his Job? I´m not yet very fit in writing makros. :-(

       

      Thanks very much.

       

       

       

        • Re: How to change the Standard format and once update the charts
          Gysbert Wassenaar

          The alternative is to use the Num() function in the expressions. You can then also define a variable with the format that should be applied and use that in the Num() function:

          Num(sum(Amount), $(vMyFormatStringVariable) ).

          • Re: How to change the Standard format and once update the charts
            jagan mohan rao appala

            Hi,

             

            In expression you can format the numbers like below

             

            =Num(Sum(Sales), 'Your format goes here')

             

            and now in Number tab uncheck Override document settings

             

            Regards,

            Jagan.

            • Re: How to change the Standard format and once update the charts
              Marcus Sommer

              You might use a macro like the following one but I wouldn't recommend it really then it's difficult to determine to which fields it should be really applied and to which not. There are many places where it could have side-effects like set analysis or already used converting/formating-functions.

               

              We have used it and the efforts to find the errors (after the first one or two I knew I had created a problem) and checking/repairing all possible other places needed at least so many time as changing everything manually.

               

              function fixFields(){

                  var fields=ActiveDocument.GetFieldDescriptions();

                  for(var i=0; i<fields.Count; i++){

                      var fd=fields.item(i);

                      if(!fd.IsSystem && !fd.IsHidden){

                          var f=ActiveDocument.GetField(fd.Name);

                          var props=f.GetProperties();

                          if(!props.NumberPresentation.Type){

                              var tags=fd.Tags;

                              for(var j=tags.lbound();j<=tags.ubound();j++){

                                  switch(tags.getItem(j)){

                                      case "$integer":

                                          props.NumberPresentation.Type=10;

                                          break;

                                      case "$ascii":

                                      case "$text":

                                          props.NumberPresentation.Type=1;

                                          break;

                                      case "$numeric":

                                          props.NumberPresentation.Type=2;

                                          break;

                                      case "$time":

                                          props.NumberPresentation.Type=4;

                                          break;

                                      case "$timestamp":

                                          props.NumberPresentation.Type=5;

                                          break;

                                      case "$date":

                                          props.NumberPresentation.Type=3;

                                          break;

                                  }

                                 

                              }

                              props.NumberPresentationSurvive = true;

                              f.SetProperties(props);

                             

                              //ActiveDocument.GetApplication().MsgBox(fd.Name+" - " +props.NumberPresentation.Type);

                          }

                      }

                  }

              }

               

              - Marcus