Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
BrandonF
Contributor
Contributor

Why is division not working on this variable script (but multiplication is?)

I have been working on a variable script to round currency to the nearest thousand, million, or billion depending on its size. It was working great a few days ago, but the problem was that I couldn't pass any set analysis to it because any commas were interpreted as a new parameter (a common problem from what I understand). I was able to get around that with using the replace() function, but now when I try to run it, it formats correctly but the values do not divide. Oddly, I tried to multiply them instead and that worked-but division does not. I'm tearing my hair out on this one, can someone please help me figure it out? 

NOTE: vCurrencyFormat is a variable that contains the formatting code for the selected currency, such as yen, dollars, euros, etc. I believe everything else should be self-explanatory.

dual(
IF(FABS($(=replace(replace('$1', ';', ','), '#', chr(39))))>1000000000,
               num(
                              $(=replace(replace('$1', ';', ','), '#', chr(39)))*0.000000001,'$(vCurrencyFormat)'&'.00B'
    ),
    IF(FABS($(=replace(replace('$1', ';', ','), '#', chr(39))))>1000000,
               num(
                                             $(=replace(replace('$1', ';', ','), '#', chr(39)))/1000000,'$(vCurrencyFormat)'&'.00M'
               ),
        IF(FABS($(=replace(replace('$1', ';', ','), '#', chr(39))))>1000,
               num(
                                                            $(=replace(replace('$1', ';', ','), '#', chr(39)))/1000,'$(vCurrencyFormat)'&'.0K'
                              ),
            IF(FABS($(=replace(replace('$1', ';', ','), '#', chr(39))))<10,
               num(
                                                                           $(=replace(replace('$1', ';', ','), '#', chr(39))),'$(vCurrencyFormat)'&'.000'
                                             ),
                                                            num(
                                                                           $(=replace(replace('$1', ';', ','), '#', chr(39))),vCurrencyFormat
                                             )
            )
        )
    )
)
,
$(=replace(replace('$1', ';', ','), '#', chr(39)))
)

  

1 Reply
Brett_Bleess
Former Employee
Former Employee

Likely going to need to attach QVW file to get responses on this one, so folks can dig into things in more detail.  You did not state what version you are running either, that would be helpful information on this one too, as there have been major changes from 11.20 track to the 12 tracks related to different aspects of things such as quoting, BNF etc. and localization settings, all of which may be in play.  I would be sure you go back and read the Release Notes between versions from which you upgraded if this is the case, in particular the What's New section, you can also find those in online Help:

https://help.qlik.com/en-US/qlikview/April2020/Content/QV_HelpSites/Whats_New_in_QlikView.htm

You can simply change the version dropdown to get the other point release info all the way back to 12.00, 11.20 was only in pdf form.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.