Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
hugmarcel
Specialist
Specialist

Use button action to set Field value to an expression

Hi

I have a button with an action to set field theField1.

Field1 shall be set to value "=DATE(MAX(Sale_Date),'DD.MM.YYYY')".

The button works, however, in selection box i get specific value "03.02.2015", but I want to have the expression in the selection box.

So If i change another field in the app, Field1 shall be set to the max(sale_date) according to the new filter selection.

Thx - Marcel

13 Replies
sunny_talwar

May be instead of using button, use 'On Selection' trigger. Every time you make a selection, the trigger will set a new Max(Sale_Date)

hugmarcel
Specialist
Specialist
Author

Thank you. Unfortunately, it does not work for me, as making selections to a specific field shall not trigger actions in all situations.

settu_periasamy
Master III
Master III

As already suggested by sunindia‌, in 'On selection' trigger, try to do the two event.. first clear your existing Field1, second select in Field is your expression

marcus_sommer

This worked for me:

='=date(max(%Datum))'

If you need to define a other date-format than the default-format it will be more tricky to get the syntax right because of the single-quotes within the date-function.

- Marcus

swuehl
MVP
MVP

Try something like

='=Sale_Date=Max(TOTAL Sale_Date)'

hugmarcel
Specialist
Specialist
Author

Hi

thank you for the answers. Unfortunately, they do not really work.

With button action, I set Field1 to expression: ='=Sale_Date=Date(Max(TOTAL Sale_Date),''DD.MM.YYYY'')'

1.) It works when I click the button. Field1 gets value of max total sale.

2.) It does not work when I change the selection so that the Max(total Sale_Date) changes.

     Field1 keeps the same value as after I have clicked the button (step 1.).

Any other idea?

Marcel

swuehl
MVP
MVP

Could you describe your data model a bit more detailed? You are not making a selection in Sale_Date, but in another Field1? How are these related in your data model?

Could you post a small sample QVW?

hugmarcel
Specialist
Specialist
Author

Hi

thank you, see QVW attached.

1.) Click the blue button.
2.) -> TransIDTest will have value 988 -> OK
3.) Select value 3 of "TransLineID" in "Transactions" tablebox
4.) -> TransIDTest will STILL have value 988 -> NOT OK

Marcel

marcus_sommer

I think the reason will be that TransIDTest is in a separat table and connected per field Num. If you creates TransIDTest within the table Transactions it will be differ - or is there a special reason why you used here an extra table, if yes it won't be clear in this example.

- Marcus