Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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 (3)
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!