Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

GetCurrentField() without IF statement

Is it not possible to use GetCurrentField directly in an expression without using it in an IF statement like so:

Count(=GetCurrentField(CustomerTopTenCycle))

Tags (1)
12 Replies

Re: GetCurrentField() without IF statement

getcurrentfield return a value so you can use it in an expression ...

Not applicable

Re: GetCurrentField() without IF statement

I'm not having any luck doing so. This is my actual expression:

Count(TOTAL {<[Fiscal Year]={'2012'}>} GetCurrentField(CustomerTopTenCycle))

If I replace the GetCurrentField function with the actual field name, it returns 35 which is correct, with the function in place, it only returns 1 for each row.

Re: GetCurrentField() without IF statement

Yes, it's a value not a reference to a field but if your field name is myField you can

Count(TOTAL {<[Fiscal Year]={'2012'}, myField={'$(=GetCurrentField(CustomerTopTenCycle))'}>} myField)

let me know

Not applicable

Re: GetCurrentField() without IF statement

"myField" is what is in question, as "myField" is determined by which field in the cycle is selected. Maybe I'm misunderstanding?

Not applicable

Re: GetCurrentField() without IF statement

Is

Count(TOTAL {<[Fiscal Year]={'2012'}>} $(=GetCurrentField(CustomerTopTenCycle)))

Working ?

Not applicable

Re: GetCurrentField() without IF statement

Thanks for the reply yadurand, but no, that doesn't work. It returns nothing with that syntax.

Not applicable

Re: GetCurrentField() without IF statement

Strange

I reproduced your fields and group names in a qvw and what i pasted is working for me

Not applicable

Re: GetCurrentField() without IF statement

Yeah, something isn't right on my end. I've tried two other cycle groups and get a result (35), but it stays the same for every field in the cycle on each group. I'm not sure if it's a Qlikview glitch, or if I'm missing something. I'll continue to investigate and update you. Thanks for your continued help.

Not applicable

Re: GetCurrentField() without IF statement

I never did get this to work correctly. It would work with some fields in the group and not others and I couldn't determine why. I eventually went with an IF statement which didn't seem to have any real performance hit.

If(

          GetCurrentField(Mon_Terr_CatSubSect_Cycle)='Ship To',

          Count(TOTAL DISTINCT {1<[Fiscal Year]={'>=$(=FiscalCurrentYear-2)<$(FiscalCurrentYear)'}>} [Ship To])

          ,

                    If(

                    GetCurrentField(Mon_Terr_CatSubSect_Cycle)='Territory',

                    Count(TOTAL DISTINCT {1<[Fiscal Year]={'>=$(=FiscalCurrentYear-2)<$(FiscalCurrentYear)'}>} Territory)

                    ,

                              If(

                              GetCurrentField(Mon_Terr_CatSubSect_Cycle)='Month',

                              Count(TOTAL DISTINCT {1<[Fiscal Year]={'$(FiscalCurrentYear)'},[Sales Amount]={'>0'}>} Month)

                              ,

                                        If(

                                        GetCurrentField(Mon_Terr_CatSubSect_Cycle)='Sales Catalog Sub Section',

                                        Count(TOTAL DISTINCT {1<[Fiscal Year]={'>=$(=FiscalCurrentYear-2)<$(FiscalCurrentYear)'}>} [Sales Catalog Sub Section])

))))

Thanks again for the suggestion.

Community Browser