Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
roxys373s
Contributor II
Contributor II

Coding a Button using field selection

Hello!

 

I need help coding a button that uses a selected field (that always has one selected value no matter what).

So basically I have a date that is selected and I need to create a button that compares another field called start date (also date format) to it. The button should show all the data for which the following statement is true: batchdate2 >= startdate.

After clicking the button, the various dates that are less than or equal to the batchdate2 selected value should become a selection so the other data that's greater than the batchdate2 value will go away (and not affect calculations).

roxys373s_0-1657289212542.png

roxys373s_1-1657289517964.png

Foe example, the data for the dates 2022-07-05 and 2023-01-03 should not be in the table once I click this button. Any ideas on how to do this? I keep wondering if there are any functions like select or createSelection(batchdate2 >= startdate). Please help if you can; I've been at this for hours, but I just don't know what to use...and also the syntax is a little confusing lol!

 

Labels (4)
5 Replies
Gui_Approbato
Creator III
Creator III

Hello,

Check this video, I believe it can help you solve it.

https://www.youtube.com/watch?v=RS7pbzPGW1I

If it doesn't, share a sample of the data if possible and we can try to work it out.

Regards

roxys373s
Contributor II
Contributor II
Author

Hello,

Thanks so much for the video! Didn't know about the Aggr function before so it helped me learn that.

 

But I'm not sure if it will help me because it's a chart function and the user should be able to check the condition batchdate2 >= startdate at any time. 

Since I'm applying this to a button, do you think the aggr function would still work? And would I select the action "Select values in a field" and then put the condition statement/expressions inside the "Value" box? (just want to make sure)

 

I didn't create a temporary table with a duplicate field since I already have the startdate field to compare to the batchdate field. Also, if you explain how Qlik will actually select the range of dates, maybe that will be helpful to understand. 

 

What more of the sample data do you need to understand the problem? 

Thanks again! 

Gui_Approbato
Creator III
Creator III

Try adding a button with this expression:

Aggr(
Only({<StartDate={">=$(=batchdate2)"}>} StartDate),

StartDate)

In short, it is a virtual table that will list the StartDates greater than the value selected in batchdate2

roxys373s
Contributor II
Contributor II
Author

Hi,

Is this correct? 

roxys373s_2-1657542976258.png

 

because when I click on the button, nothing happens? Do I need to drag in a table from the list of charts? 

 

Gui_Approbato
Creator III
Creator III

The button will filter values in a list, so you need to pass them like --> Value1,Value2,Value3 ..

For that, just add the concat function:

Concat ( distinct Aggr(
Only({<StartDate={">=$(=batchdate2)"}>} StartDate),

StartDate) , ',')