Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Highlighted
cbaqir
Valued Contributor

GetCurrentField vs Set Analysis

I have a chart that has two expressions:

Calculate Total Spend to Date:

sum(ACT_AMT)/1000

Calculate current fiscal year spend:

=Sum({$<FISCAL_YEAR_NUM={$(=$(vCurFY))}>}ACT_AMT)/1000

I have a new requirement that instead of hard coding the current fiscal year in the expression, the user shall be able to select the Fiscal Year (FY) from the list box (FISCAL_YEAR not FISCAL_YEAR_NUM) and the total displayed should show the total for only the selected year(s).

I thought I could use =GetCurrentField(FISCAL_YEAR) instead of {$<FISCAL_YEAR_NUM={$(=$(vCurFY))}>} but that doesn't seem to work. I know that this is simple but my brain just isn't connecting the dots today.

Sample Attached. For example, clicking on FY16 (the current FY) works but FY15 does not.

Thanks!

Cassandra

13 Replies
MVP
MVP

Re: GetCurrentField vs Set Analysis

GetCurrentField(.. ) is used to get the active Field in a dimension (drill down or cyclic) group.

I think you are looking for

=GetFieldSelections(FISCAL_YEAR)

krishna_2644
Valued Contributor III

Re: GetCurrentField vs Set Analysis

See attached.

variable p: =chr(39) & GetFieldSelections(FISCAL_YEAR)  & chr(39)

in chart:  =Sum({$<FISCAL_YEAR_NUM={$(p)}>}ACT_AMT)/1000

cbaqir
Valued Contributor

Re: GetCurrentField vs Set Analysis

Thanks, but that does not appear to work in my app for some reason.

=Sum(GetFieldSelections(FISCAL_YEAR)}>}ACT_AMT)/1000

cbaqir
Valued Contributor

Re: GetCurrentField vs Set Analysis

That doesn't seem to be responding to my selection in FISCAL_YEAR list box

MVP
MVP

Re: GetCurrentField vs Set Analysis

It would be more like

=Sum({$<FISCAL_YEAR={$(=GetFieldSelections(FISCAL_YEAR))}>}ACT_AMT)/1000

But since QV considers selections in this field anyway for aggregations, the set expression wouldn't make much sense.

krishna_2644
Valued Contributor III

Re: GetCurrentField vs Set Analysis

you have almost similar data in ACT_AMT for all the years for some reason.Please check that.

If the Data in ACT_AMT if different then definitely the chart responds.

edit:

for some reason , the sum(ACT_AMT) is constant and list box values are also the same for all the years.

Capture1.PNG

Thanks

mphekin12
Valued Contributor

Re: GetCurrentField vs Set Analysis

I think you may be having issues because of your data model.  The two tables in your model aren't linked.

Not applicable

Re: GetCurrentField vs Set Analysis

I noticed in the text box to the left, there was not a value being returned.  I thing you may need to use =GetFieldSelections(FISCAL_YEAR)

I do not know what impact if any that will/may have

Whenever I selected the different fiscal years, the data did not change - is the data that is shown for FY16?

based on the Help, it does not appear getcurrentfield is the correct function for what you are trying to achieve

GetCurrentField(groupname)

returns the name of the field currently active in the group named groupname.

Example:

getcurrentfield( MyGroup )

cbaqir
Valued Contributor

Re: GetCurrentField vs Set Analysis

=Sum({$<FISCAL_YEAR={$(=GetFieldSelections(FISCAL_YEAR))}>}ACT_AMT)/1000 seems to work. Are you saying it shouldn't?

The only issue I see is that it is showing 0 if none of the FYs are selected.