Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customers, Partners & Luminaries only: You're invited to a Data Analytics Roadmap session. Read More
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

Problem doing a function

Hi All!!

I'm trying to do a function like i show, but i can't get the result that i hope.

The function it's transformating the value of the parameter to a format value even Milllion, thousands....

Here I put some examples to do this with a function:

SUB formatNum (Value)

  IF Value<num(100000) THEN

  Value = Num(Value,'#.##0 €;-#.##0 €')

  ELSEIF Value<num(1000000)

  Value = Num(Value/num(1000),'#.##0,0 k€;-#.##0,0 k€')

  ELSE

  Value = Num(Value/num(1000000),'#.##0,00 M€;-#.##0,00 M€')

  ENDIF

ENDSUB

OR with a Calculated Variable:

LET suma= 'IF($1<num(99999), Num($1,"#.##0 €;-#.##0 €"), IF($1<num(1000000), Num($1/num(1000),"#.##0,0 k€;-#.##0,0 k€"), Num($1/num(1000000),"#.##0,00 M€;-#.##0,00 M€")))';

The code its rigth, but i can't call the sub function from an text object, and i can't get the correct result with the calculatedValue because I dont escape the simple comma char.

Note: to call the calculated variable use:

=$(suma(3131231211231223))

Thanks All and Regards.

Kind Regards,
Enrique Mora.
1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Try this:

SET suma= IF($1<num(99999), Num($1,'#.##0 €;-#.##0 €'), IF($1<num(1000000), Num($1/num(1000),'#.##0,0 k€;-#.##0,0 k€'), Num($1/num(1000000),'#.##0,00 M€;-#.##0,00 M€')));


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Try this:

SET suma= IF($1<num(99999), Num($1,'#.##0 €;-#.##0 €'), IF($1<num(1000000), Num($1/num(1000),'#.##0,0 k€;-#.##0,0 k€'), Num($1/num(1000000),'#.##0,00 M€;-#.##0,00 M€')));


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Creator
Creator

Thank you!! It's a good solutions and learn how to resolve it!!

Kind Regards,
Enrique Mora.