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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
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 (1)
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