Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)))
)
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