Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

How to get selected value of field in Script ??

How to get selected value of field in Script ??

I tried GetCurrentField[FiscalYear] ; but it does not work out.

Thanks

1 Solution

Accepted Solutions
Highlighted

Re: How to get selected value of field in Script ??

BTW try this expression:

If (_CalendarType = 'Fiscal' , GetFieldSelection([Fiscal Year]), if (GetSelectedCount(_CalendarType) = 0, $(vSalesBookUsage)))


If SalesBookUsage is a field (i.e. an Amount) put an aggregation expression in vSalesBookUsage, like


SET vSalesBookUsage = 'Sales Book Usage = ' & sum(SalesBookUsage);


or define something similar in the Variable Overview.


Best,


Peter

View solution in original post

16 Replies
Highlighted

Re: How to get selected value of field in Script ??

Try With

=Getfieldselections( [FiscalYear] )

Regards

Anand

Highlighted
Partner
Partner

Re: How to get selected value of field in Script ??

Hi Nikhil,

GetCurrentField works on groups - the parameter should be a group name.  It does not operate on fields (the function name is not particularly clear)

Have you looked at the syntax for getfieldselections()?

Hope this helps!

Highlighted
Employee
Employee

Re: How to get selected value of field in Script ??

GetCurrentField can't be used in a script.

It can only be used in chart expressions in the UI.

Highlighted
Specialist
Specialist

Re: How to get selected value of field in Script ??

Hey,

It works but now i want if nothing is selected in _CalendarType then SalesBookUsage should be visible in straight table caption. How can i acheive this??

My script is:

If(_CalendarType = 'Fiscal' , GetFieldSelection([Fiscal Year])).

thanks

Highlighted
Specialist
Specialist

Re: How to get selected value of field in Script ??

Hey,

It works but now i want if nothing is selected in _CalendarType then SalesBookUsage should be visible in straight table caption. How can i acheive this??

My script is:

If(_CalendarType = 'Fiscal' , GetFieldSelection([Fiscal Year])).

thanks

Highlighted

Re: How to get selected value of field in Script ??

Hi,

Use variable here try dynamically store the SalesBookUsage value in the variable and then use it here in the variable.

Ex:-

If(_CalendarType = 'Fiscal' , GetFieldSelection([Fiscal Year]), $(vSalesBookUsgae) ).


Also it does not seems your expression works in getfieldslection condition check once but you deleted the eariler messsage on that i explain the correct way to use the getfieldselections().


Ex:- Like this ways

if( GetFieldSelection(_CalendarType) = 'Fiscal' , ([Fiscal Year]), $(vSalesBookUsgae) )


Regards

Anand

Highlighted
Specialist
Specialist

Re: How to get selected value of field in Script ??

Hey ,

Thanx anand but still my problem is not solved.

My expr is like:

=if(_CalendarType = 'Fiscal' , GetFieldSelections([Trade Fiscal Year]) & '-' & GetFieldSelections([Trade Fiscal Quarter]) ,

if(vTradeCalendarDateType = '1D' , date(max({1}TradeDateMaster), 'MM/DD/YYY') , $(vSalesbookUsage))

)  Now when i select any date, in my table caption date is visible but when i clear everything then still last selected date is there. But i want when i clear everything , SalesbookUsage should be visible.

What to do??

Highlighted

Re: How to get selected value of field in Script ??

Nikhil,

you're talking about expressions, not about any script. With script, people refer to the load script as presented in the script editor (File->Edit Script...) That's an entirely different ball game.

Highlighted

Re: How to get selected value of field in Script ??

BTW try this expression:

If (_CalendarType = 'Fiscal' , GetFieldSelection([Fiscal Year]), if (GetSelectedCount(_CalendarType) = 0, $(vSalesBookUsage)))


If SalesBookUsage is a field (i.e. an Amount) put an aggregation expression in vSalesBookUsage, like


SET vSalesBookUsage = 'Sales Book Usage = ' & sum(SalesBookUsage);


or define something similar in the Variable Overview.


Best,


Peter

View solution in original post