Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
mishraamit2485
Creator
Creator

Substitute for set clear state

Hi All,

In my dashboard i'm showing the two quarters worth of data, current and previous quarter also monthly data, to get the quarterly data i'm using set analysis and adding three months of data to show quarter data and it's working well.

The problem is when I hit the clear button it clears current quarter data and starts showing data for both the quarters(Requirement is tho show only current quarter data when user hits clear), to overcome from this I did set clear state and able to achieve that...but it does not work when new data set comes(means new quarter).

e.g. I have data for Q2 and Q3 i set clear state on Q3, so when ever i hit the clear button it will go to Q3 irrespective of my current selection....now new data has come Q4 and Q3(every quarter we get data for current and previous), now if I hit the clear button it goes to Q3 as when i set the clear state it was Q3 and Q2..my requirement is whenever i hit clear it should always go to current quarter.

Attaching the sample app

I have 2 inline table first, with 1st data set I have setup a clear state for qtr 2 so when ever you hit clear it will go to qtr 2...now when we comment data set 1 and uncomment data set 2 and reload the script you will still see it goes to 2nd qtr where as I want to go to 3rd qtr as  that is the latest.

Note: I can not do always one selected it is hampering my other features.

9 Replies
jsingh71
Partner
Partner

Create quarter filter and select always one selected value.

Share sample application then its easy to provide solution.

mishraamit2485
Creator
Creator
Author

Actually i did that, but if i do always one selected it does not allow me to select individual months as qtr is always selected and month is nothing but the split of quarter..

mishraamit2485
Creator
Creator
Author

attached the sample app.

jonathandienst

Rather than using the clear state to preselect the latest period, include a set expression in your charts/tables that select the Max period. If nothing is selected, then the Max will be the most recent period; if a period is selected, then the Max will be the selected period.

I usually define a variable vMaxDate like this:  =Date(Max(ReportDate)) // the = is part of the definition

eg in LOAD  Set vMaxDate = '=Date(Max(ReportDate))';

Then is use the set expression:

     Sum(<ReportDate = {'$(vMaxDate)'}>} Amount)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
mishraamit2485
Creator
Creator
Author

Will that work if i hit the clear button, also i want to implement this in button instead of chart or report (if nothing is there select Max Date) will it be possible in button itself?

But it should not get cleared when i hit the clear button.

mishraamit2485
Creator
Creator
Author

I do not think we can not select any field when we hit the clear, even if i set the variable in the button it will be cleared when we hit the clear button.

mishraamit2485
Creator
Creator
Author

Any input on that?

jonathandienst

>>Will that work if i hit the clear button, also i want to implement this in button instead of chart or report (if nothing is there select Max Date) will it be possible in button itself?

Yes. vMaxDate will default to the most recent date in the model when nothing is selected (ie when selections are in the clear state)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
cjohnson
Creator II
Creator II

Hi Amit,

Here is another option:

1. You can create a flag in the script to be the current quarter.

2. You can set this flag = 1 whenever your data is data for the current quarter.

3. Use this flag to set clear state instead. It will then get updated as the quarters also get updated.

Please see attached for more information. In the attached example I have

    vCurrentQtr = 2 (which you can change to 3 as desired), but ideally it would be whatever the current quarter is. So the real calculation would be similar to below:

Let vCurrentQtr = ceil(month(today())/3)

Thanks,

Camile