Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis using Field Value

I am very new to QV and set analysis.  I am trying to do a calculation based on a field value.  The statement I currently have

Avg({<[Issue Date]={'<=10/27/14'},[Exchg]={N}>}[Amount])  works with a hard coded date (10/27/14).  What I want to do is replace the date with a field (MyField) from my table that has a moving date.  In summary, I need to perform this calculation when Issue Date <= MyFieldValue

Anyone know how I can achieve this?

Thanks in advance.

1 Solution

Accepted Solutions
Not applicable
Author

Hi L R.

Thank you for the attached file.

Look at my reply, your calculation is performed in two steps. This makes it less complex.

Step1 - differs records using conditional Type

04-11-2014 09-11-54.jpg

Step2 - insert distinct Type in your set analysis:

Prior Calculation: Avg({<Type={'Prior'},[Issued in Exchange]={N}>}[Total Doc Amount])

Post Calculation: Avg({<Type={'Post'},[Issued in Exchange]={N}>}[Total Doc Amount])

This is a great way to perform conditional and f calculations.

I hope that will help you!

View solution in original post

12 Replies
dickelsa
Creator
Creator

see post below:

Re: How to specify explicit &gt; and &lt; in set modifier

also, you should put {N} as {'N'}

Regards,

Dick

morganaaron
Specialist
Specialist

Try: Avg({<[Issue Date]={"<=$(=max(Date(MyField)))"}, Exchg={'N'}>}Amount) if you want it to be less than a date selected in "MyField".

MK_QSL
MVP
MVP

Avg({<[Issue Date]={'<=$(=Max([Issue Date]))'},[Exchg]={'N'}>}[Amount])

Not applicable
Author

If you could attach a sample file I could solve your problem.

Not applicable
Author

I think the best way to handle this problem is to create a variable directly in load script and then use it in your set expression.

For example,

Load Script:

vMaxDate = Date(Peek('MyField',0,'YourTableNameInQlik'))

Set Expression:

Avg({<[Issue Date]={"<=$(vMaxDate)"},[Exchg]={'N'}>}[Amount])

Not applicable
Author

Sorry, I forgot "LET" statement, try this:

Load Script:

LET vMaxDate = Date(Peek('MyField',0,'YourTableNameInQlik'))     //replace table name with your table name

Set Expression:

Avg({<[Issue Date]={"<=$(vMaxDate)"},[Exchg]={'N'}>}[Amount])

satishkurra
Specialist II
Specialist II

Hi

LET vDate = Date#(Peek('FieldName',0,'TableName'))   

Expression:

Avg({<[Issue Date]={"<=$(vDate)"},[Exchg]={'N'}>}[Amount])

Not applicable
Author

I've put together an example of what I'm looking to do.

The attached xls has sample data.  I've calculated to the right what the Prior and Post Columns in QV should reflect.  If the Issue Date <= ValidateDate it goes in Prior Bucket, if the Issue Date > ValidateDate it goes in Post Bucket.

Thanks for your help!

Not applicable
Author

Hello Carlo,

I've put together an example of what I'm looking to do.

The attached xls has sample data.  I've calculated to the right what the Prior and Post Columns in QV should reflect.  If the Issue Date <= ValidateDate it goes in Prior Bucket, if the Issue Date > ValidateDate it goes in Post Bucket.

Thanks for your help!