Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi to all.
On a document I have some triggers to select the current year, period and week and this works fine but the problem comes when I open the document to make a few changes and then save the selections for these filters are also saved and the trigger stops working.
We are used to have reports that automatically select the current week or period and in this case I was suggested to use the function max() to select the current conditions but when I save the document seems that the selection is kept and the function max() selects the value based on this previously filtered value.
I'd like to know if there's a way to select the current week, period, year (or whatever) without taking in consideration any filter (but be able to select a different one) or maybe a way to reset this values whe the document is closed. The approach is to have selected the current date values.
I hope I was clear.
thanks in advance.
Technically, the different actions are not guaranteed to occur in order on a multi-processor machine, but it's never caused me much trouble, so I get lax about it. That ended up biting you this time. Sorry about that. I created a sample application and got the same problem you did with the max(Date). Using max({1} Date) seemed to fix it.
See the attached, which works in practice, at least on my computer.
QlikTech really needs to provide an option to guarantee that actions occur in sequence when a sequence is important.
Use the OnOpen trigger (settings -> document properties -> triggers). Using triggered actions, clear all then make the selections. If the action selects the max date, it will be the max date when the document is opened, not when you save it, and if you accidentally make selections when you save and install, the clear all will remove them. You can do the same thing with a macro if you're on an older version of QlikView that doesn't support actions.
That is a great idea, I'll try it right away but also leads me to another question, how do you manipulate the controls on the macro editor? can I change the behavior of every element on the document even variables?
You can do just about anything with macros if you can make any sense of the API guide. Yes, you can set variables. Here's an example macro setting both fields and variables:
sub PromisePerformanceOrders
activedocument.clearall false
set field = activedocument.fields("Skip Cancelled Order Items?")
field.select "Y"
field.lock
set field = activedocument.fields("Order Item Type")
field.select "PRIME"
set field = activedocument.fields("Forecast?")
field.select "N"
set field = activedocument.variables("PromisePerformanceOrders")
field.setcontent activedocument.evaluate("getcurrentselections()"),false
end sub
Hello John.
Seems that is not working, I tryied the triggers with Select in field with blank, clear other fields, clear all and the macro option and the max() function does not work.
It is like the select in field with the max() function executes at the same time or maybe before the select field for year (I'm testing with it) and it is selecting the last saved option as max. On the event trigger I put the "clear" at the beginning and the "select in field" event with max() at the end.
Is there anything that I am missing?
Technically, the different actions are not guaranteed to occur in order on a multi-processor machine, but it's never caused me much trouble, so I get lax about it. That ended up biting you this time. Sorry about that. I created a sample application and got the same problem you did with the max(Date). Using max({1} Date) seemed to fix it.
See the attached, which works in practice, at least on my computer.
QlikTech really needs to provide an option to guarantee that actions occur in sequence when a sequence is important.
Thank you John, I found a way to override this.
You really help me. And for my experience now I know that this is not executed sequentially so I had to modify a little the expression with {1} as you said.
Thanks