Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
Contributor II

Set Analysis Formula with Parameter

Hi together,


I have the following Set Analysis Formula with Parameters:

fCount =Count({$< Field1 = {'$1'}, Field2  = {'$1'}, Date = {$(=$5)}  > } [Value]  )

If I set the values and variables directly into the formula, like

fCount =Count({$< Field1 = {'value1'}, Field2  = {'value2'}, Date = {$(=$(vD_AddXMonthsRange(-6)))}  > } [Value]  )


it works. But if I want to use the formula with Parameters, like


=$(f_Count(value1,value2,$(vD_AddXMonthsRange(-6))))


i got an error. Unfortuanetly I can´t find the error for this


Thanks for your help!


6 Replies
Highlighted

Re: Set Analysis Formula with Parameter

Add single quotes to the parameter 3

=$(f_Count(value1, value2, '$(vD_AddXMonthsRange(-6))'))

Also, replace $5 by $3

Highlighted
Contributor II
Contributor II

Re: Set Analysis Formula with Parameter

Hey Miguel,

thanks for you reply. Unfortunately it not helps.

For better understanding, followed my formula for vD_AddXMonthsRange:

CHR(39) & '>=' & AddMonths(vD_CurrentDateInput, $1) & '<=' & vD_CurrentDateInput & CHR(39)

I used $1, $2 and $3. It was only a mistake in my post

Best regards

Highlighted

Re: Set Analysis Formula with Parameter

Is the output of the AddMonths() function in the same format than the field "Date"?

Also, always use Chr(34) or " when the right side of the set modifier is a search (in this case, a range) and not a fixed value.

Highlighted
Contributor II
Contributor II

Re: Set Analysis Formula with Parameter

Hey Miguel,

the format from the AddMonths function is in the same Format. Please find attached my Test-Application about this problem.

I tried to use Chr(34), but I have the same problem .

Highlighted

Re: Set Analysis Formula with Parameter

I would go for modifying the fSum variable to

Sum({$<

  Field1  = {'$1'},

  Field2  = {'$2'},

  Datum = {">=$(=AddMonths(Datum, $3))<=$(=Date(Max(Datum)))"}

  >}

  [Value]

)

The expansion within the expansion, while maybe possible, is returning already calculated values instead of text. This expression above in the fSum will work, though.

Highlighted
Contributor II
Contributor II

Re: Set Analysis Formula with Parameter

Hi Miguel, thanks for your response.

Unfortunately, if I use this formula I´m not so flexible, because I don´t want only use formulas like the  AddXMonths, I want to use also some other formulas for set the Date Parameter