Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
BrianDH
Creator II
Creator II

Compare 2 values (formatted)

I need to compare two number fields.  One number comes to me as #,### the other #,###.## So I also need to format these to read the same.

 

if (num((Sum(BUDGET_AMT) / count(PROJECT_ID)), '#,###,###,#00') <> num(Sum(BH_AMOUNT_BUD), '#,###,###,#00'),MasterKey)

No error and way too many results. 

 

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

To format a number doesn't changed the value. This means - if this kind of adjustment is really needed for your data/results - you need to convert them - maybe per num#() - or to cut them - maybe per left/right/mid() or (probably more suitable) to round them - per round/floor(ceil(). I think I would use something like this:

if(floor(Sum(BUDGET_AMT) / count(PROJECT_ID)) - floor(Sum(BH_AMOUNT_BUD)), MasterKey)

You might need to use a different rounding-function and/or specifying the needed number of digits for it.

- Marcus

View solution in original post

3 Replies
felipessj
Contributor III
Contributor III

A question.

Do those numbers come in a number format (if you multiply them by 1 gives you the same number)?

If so, you should not have problems comparing them. 1,234 = 1,234.00 -> true.

if they come as text,

you should delete the characters that make the separation of thousands and pass it to decimal with the format you want

marcus_sommer

To format a number doesn't changed the value. This means - if this kind of adjustment is really needed for your data/results - you need to convert them - maybe per num#() - or to cut them - maybe per left/right/mid() or (probably more suitable) to round them - per round/floor(ceil(). I think I would use something like this:

if(floor(Sum(BUDGET_AMT) / count(PROJECT_ID)) - floor(Sum(BH_AMOUNT_BUD)), MasterKey)

You might need to use a different rounding-function and/or specifying the needed number of digits for it.

- Marcus

BrianDH
Creator II
Creator II
Author

Rounding that is the ticket!  Thanks!