Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Create quarter filter and select always one selected value.
Share sample application then its easy to provide solution.
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..
attached the sample app.
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)
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.
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.
Any input on that?
>>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)
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