Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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))

12 Replies
alexandros17
Partner - Champion III
Partner - Champion III

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

Not applicable
Author

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.

alexandros17
Partner - Champion III
Partner - Champion III

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
Author

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

Not applicable
Author

Is

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

Working ?

Not applicable
Author

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

Not applicable
Author

Strange

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

Not applicable
Author

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
Author

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.