Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
paul_ripley
Creator III
Creator III

Round to 2 decimal places within an IF statement

Hello

I have an IF statement at the moment which works.  In the second clause of the IF statement I want to round the number to 2 decimal places (see below) , and when I do this i get the error 'Error in expresison.  If takes 2-3 parameters.  I dont get this error until i put the round clause around the sum statement. 

Can you help?

Thanks

 

 

=IF

(fabs((sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 = {110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
-
sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 = {110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Actual'}
>} GBP)

)

/

sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
) >1 , '>100%',

 

round(
(sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
-
sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 = {110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Actual'}
>} GBP)
)
/

sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
)
,0.01)

 

 

 

Labels (2)
1 Solution

Accepted Solutions
anushree1
Specialist II
Specialist II

I think its because the braces are not closed properly , plz try below:

round(
(sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
-
sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 = {110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Actual'}
>} GBP)
)
/

sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP),0.01
)

View solution in original post

2 Replies
anushree1
Specialist II
Specialist II

I think its because the braces are not closed properly , plz try below:

round(
(sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP)
-
sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 = {110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Actual'}
>} GBP)
)
/

sum({$<period = {">=$(vStartPeriod_CY)<=$(vEndPeriod_CY)"},
bud2 ={110,111,112,113,114,123,124,300,310,320,330,340,200,120,121,122,130,140,160,150,260} , busarea = {PE},
Datasource = {'Budget'}
>} GBP),0.01
)

paul_ripley
Creator III
Creator III
Author

Many thanks that worked