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: 
Adforma
Contributor II
Contributor II

Get a percentage in a calculated field

Hello to all
Help: 😱

The expression: = num (Sum ({<Year = {$ (= Max (Year))}>} Amount),) / num (Sum ({<Year = {$ (= Max (Year) -1)}>} Amount) * (1+ (Budget))) * 100 gives me the result: 54,57820 ...
I want to get 58.78%, but I don't understand how and where to put in the right syntax the expression percentage: '#, ## 0.00%' with the right parentheses.
Can you help me?
Thanks in advance ...
Luigi

6 Replies
Vegar
MVP
MVP

Firstly: You are multiplying by 100 which transforms your 0.58 (58%) into 58 (5800%)

Secondly: you only need one NUM() in the whole expression, a NUM() that is wrapping the whole expression. 

Thirdly: if you need help with the fact that you are getting the value 54 but expect the value 58 then you will probably need to provide us with more information.

 

Good luck

Adforma
Contributor II
Contributor II
Author

Thanks Vegar for the answer.
I was searching something as this:
=num(Sum({<Year={$(=Max(Iear))}>} Revenue),'#.##0,00 €') 
that f.i. give me this: 4.500,00 € 
but in my expression:
=num(Sum({<Year={$(=Max(Year))}>} Revenue),)/num(Sum({<Year={$(=Max(Year)-1)}>} Revenue)*(1+(Budget)), '#,##0.00%')
 the Expressionis OK but the string 
'#,##0.00%'
unfortunately is ininfluent.

Thanks in advance

Luigi

 

 

Vegar
MVP
MVP

If the expression is correct then you're  almost there, you just need to get the formatting  correct. 

If it's not working for you like you wrote then you might need to make use of the second and third parameters in the num function (the delimiters). Take a look at the help page for info: https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Forma...

 

Sometimes it's just as easy to do the number formatting in the chart object properties. You could give that approach a go as well. 

 

Good luck

StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

try to use num only once:

 

num(
Sum({<Year={$(=Max(Year))}>} Revenue)
/
Sum({<Year={$(=Max(Year)-1)}>} Revenue)*(1+(Budget))

, '#,##0.00%')

Vegar
MVP
MVP

It looks like  @StarinieriG  expression should work, but I'm just concerned about your final product (1+(budget))

Are you aware that you only get an value from budget when you have a single value per dimension combination in your chart? 

(1 + (budget)) is equvivalent to (1 + only(budget))

Brett_Bleess
Former Employee
Former Employee

Bergamo, did the last posts get you what you needed, or are you still working on things?  If the posts did help, please use the Accept as Solution button to mark the one(s) that got you what you needed.  If you did something else, please consider posting that and then mark that as the solution for future visitors, and if you are still working on things, leave an update as to where you stand.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.