Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kakaderanjit53
Creator III
Creator III

Custom or User Defined Function Issue

Hi Experts,

I want to know is it Possible to Pass If Condition as a Parameter to Custom Function

Here Is the Scenario

1. I Have Been Created One Variable in Script Level i.e

SET FormatNumber=Dual(

    if($1>=10000000,num($1/10000000,'₹ ##.##Cr'),

if($1>=100000,num($1/100000,'₹ ##.##L'),

if($1>=1000,num($1/1000,'₹ ##.##K'),

$1))) ,$1);

I Have Been Created One Variable in Frontend i.e  vCondition this variable contains expression like below

if(Measures='Logins',$(vTotalLogins),
if(Measures='Clients Traded (Unique)',$(vUniqueClientsTraded),
if(Measures='Volume (Cr)',$(vTotalVolume),
if(Measures='Brokerage in Lacs (Gross)',$(vBrokerage),
if(Measures='No. of Trading Days',$(vNoftradingdays),
if(Measures='Avg. brokerage per client',$(vAvgClientBrokerage),
if(Measures='Avg. daily login',$(vAvgDailyLogins),
if(Measures='Avg. daily brokerage',$(vAvgDailyBrokerage),
if(Measures='Avg. daily volume',$(vAvgDailyVolume)
)))))))))

here I am passing vCondition as a parameter to FormatNumber like below

$(FormatNumber($(vCondition)))

But I unable to get the expected result .

2. i want to know one more thing

i.e is it possible to pass field as a parameter

Hello Qlik Experts,

Please provide me the correct solution to overcome the above problem.

jagand.pranskusmarcus_sommersunny

2 Replies
marcus_sommer

Try something like: $(FormatNumber($(=vCondition))) or $(FormatNumber($(=$(vCondition)))).

- Marcus

d_pranskus
Partner - Creator III
Partner - Creator III

Hi

Probably this is a late reply, nevertheless, the problem might be related to vCondition having commas (,) in the expression. So when you pass it as a parameter, Qlik expands it and thinks that you have passed many parameters, separated by comma (,), therefore it fails.

Solution would be to replace all comas in vCondition with semicolons(;). Then in format expression

replace $1 with $(=REPLACE('$1', ';', ',')))

Also you are using other variables like $(vTotalLogins)m if any of these contains comas, the same story applies.

Regards

Darius