Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rajtechnocraft
Contributor III
Contributor III

Alternative to set analysis ??

Hi , All

I am using SET analysis for YTD and other calculations,

sum({<MKPF.YearMonth = {"$(='<='&Only(MKPF.YearMonth)&'>'&Only(date(addmonths(MKPF.YearMonth,-1),'MMM-YYYY')))"}>} (if(MSEG.LOG_MSEG_MKPG.XAUTO<>'X',MSEG.LOG_MSEG_MKPG.Debit1)))

This logic is working on desktop model but fails on Browser deployment..

Can u suggest alternative Logic of set analysis..

Thanks

9 Replies
Not applicable

Hi,

I prefer using flags instead of set analysis.

Create Field: YTD_Flag in your script. Assign value ='1' when the line qualifies a YTD. In your expression use sum(sales * YTD_Flag).

This will return the SUM(Sales) where YTD_Flag=1 and null when YTD_Flag<>'1'

This is much simpler and I believe improves performance of you charts as well.

Regards,

rajtechnocraft
Contributor III
Contributor III
Author

Thanks for the reply ,

What if i want to Calculate values for Last 23 months or 25 months (dynamic) ,,

can u give some example ???

rajtechnocraft
Contributor III
Contributor III
Author

i want to Calculate values for Last 23 months or 25 months (dynamic) ,,

can u give some example ???

johnw
Champion III
Champion III


wernbrenk wrote:I prefer using flags instead of set analysis.
Create Field: YTD_Flag in your script. Assign value ='1' when the line qualifies a YTD. In your expression use sum(sales * YTD_Flag).
This will return the SUM(Sales) where YTD_Flag=1 and null when YTD_Flag<>'1'
This is much simpler and I believe improves performance of you charts as well.


I'm a fan of flags too. But you can also write the expression like this:

sum({<YTD_Flag={1}>} sales)

Which isn't particularly complicated. As for comparative performance, that's an ongoing debate and can depend on your data model. That said, my own testing shows that set analysis is faster, and I also have this quote from a senior support technician:

"* SA SHOULD be faster than IF because of the way SA are using the selection engine (whereas IF has to aggregate all data).
* Flag multiplication will almost always be slower because it costs more, AND needs to aggregate all data.

...

Now, the reason to why I am using a capital "SHOULD" all the time, is that during the tests, we discovered that code involved in SA and the calculation of certain data structures and in certain scenarios could be greatly enhanced; something that also has been done now. We are in our tests seeing a great increase of speed in SA expressions, and actually in many cases besides that. Some had to do with parallelism issues, others did not. We've done tests on other large customer live data, and in those cases we're now sometimes seeing more than a 50% increase in SA expression calculation speed. Others have also noticed this decrease in performance, just as you did. Although these changes are going to be present in SR1 of v9, some others are further in the future. But SR1 is going to be much faster than 7119 in some cases, that's for sure."

None of this addresses the original question, of course. I haven't played with browser deployment, but if you're convinced that set analysis is the problem, I'd frankly report it to QlikTech. The browser deployments SHOULD work properly, after all.



rajtechnocraft
Contributor III
Contributor III
Author

I Have already reported the matter to support@qliktech.com , but no reply till date..

Can the data for last 26 or 28 months ,, (on selection) be found using the flags..

johnw
Champion III
Champion III

OK, so what you want to do is select a month, and see the past, say, 25 months based on the month selected. And you need to do it without set analysis because you're having a problem deploying it to the browser, and QlikTech isn't replying to you.

I don't think you want flags in this case. One approach would be to add a new table to tie together the selected month to the past 25 months:

Range, Year Month
Sep 07 - Sep 09, Sep 07
Sep 07 - Sep 09, Oct 07
...
Sep 07 - Sep 09, Sep 09
Aug 07 - Aug 09, Aug 07
Aug 07 - Aug 09, Sep 07
...
Aug 07 - Aug 09, Aug 09
...

That then uses QlikView's normal logic pull up the selected range, no set analysis or funny expressions needed.

As for how to LOAD the table, probably something like this (untested):

[Rolling 25]:
LOAD
date(addmonths("Year Month",-24),'MMM YY') as "Starting Year Month"
,"Year Month" as "Ending Year Month"
RESIDENT [Calendar]
;
LEFT JOIN ([Rolling 25])
LOAD "Year Month"
RESIDENT [Calendar]
;
INNER JOIN ([Rolling 25])
LOAD
"Starting Year Month"
,"Ending Year Month"
,"Starting Year Month" & ' - ' & "Ending Year Month" as "Range"
RESIDENT [Rolling 25]
WHERE "Year Month" >= "Starting Year Month"
AND "Year Month" <= "Ending Year Month"
;
DROP FIELDS
"Starting Year Month"
,"Ending Year Month"
;

rajtechnocraft
Contributor III
Contributor III
Author

thanks for reply and your effort will try this today .

Not applicable

Hello John,

I am trying to use rangesum formula in my load script to calculate year-to-date demand for 27 months. Could you please guide me where i am doing wrong ? I am currently working on version 8.20 therefore i don't have privilege to use set analysis or other new techniques.

I am currently using following expression to calculate YTD sum of demand, however; I want to push this expression to Load script.

Current Expression :- rangesum(Above(ActualDemand,0,12))

Following Load Scrips don't produce correct result.

Load

Date,

ActualDemand,

rangesum(Previous(ActualDemand),ActualDemand) as Dmd,

Rangesum(ActualDemand, Peek(ActualDemand,0,12)) as Test

Resident Test

;



Not applicable

<body><p>How to accomplish &quot;Rangesum&quot; in load script ? </p> <p> </p> <p><col width="102"></col><col width="102"></col><col width="100"></col> <tr> <td width="102" class="xl65" height="18">Date</td> <td width="102" class="xl65">Actual Demand</td> <td width="100" class="xl65">Rangesum</td> </tr> <tr> <td align="right" class="xl66" height="18">1</td> <td align="right" class="xl66">454</td> <td align="right" class="xl66">454</td> </tr> <tr> <td align="right" class="xl66" height="18">2</td> <td align="right" class="xl66">65</td> <td align="right" class="xl66">519</td> </tr> <tr> <td align="right" class="xl66" height="18">3</td> <td align="right" class="xl66">454</td> <td align="right" class="xl66">973</td> </tr> <tr> <td align="right" class="xl66" height="18">4</td> <td align="right" class="xl66">65</td> <td align="right" class="xl66">1038</td> </tr> <tr> <td align="right" class="xl66" height="18">5</td> <td align="right" class="xl66">454</td> <td align="right" class="xl66">1492</td> </tr> <tr> <td align="right" class="xl66" height="18">6</td> <td align="right" class="xl66">567</td> <td align="right" class="xl66">2059</td> </tr> <tr> <td align="right" class="xl66" height="18">7</td> <td align="right" class="xl66">897</td> <td align="right" class="xl66">2956</td> </tr> <tr> <td align="right" class="xl66" height="18">8</td> <td align="right" class="xl66">4534</td> <td align="right" class="xl66">7490</td> </tr> <tr> <td align="right" class="xl66" height="18">9</td> <td align="right" class="xl66">567</td> <td align="right" class="xl66">8057</td> </tr> <tr> <td align="right" class="xl66" height="18">10</td> <td align="right" class="xl66">565</td> <td align="right" class="xl66">8622</td> </tr> <tr> <td align="right" class="xl66" height="18">11</td> <td align="right" class="xl66">56</td> <td align="right" class="xl66">8678</td> </tr> <tr> <td align="right" class="xl66" height="18">12</td> <td align="right" class="xl66">76</td> <td align="right" class="xl66">8754</td> </tr> <tr> <td align="right" class="xl66" height="18">13</td> <td align="right" class="xl66">345</td> <td align="right" class="xl66">8645</td> </tr> <tr> <td align="right" class="xl66" height="18">14</td> <td align="right" class="xl66">567</td> <td align="right" class="xl66">9147</td> </tr> <tr> <td align="right" class="xl66" height="18">15</td> <td align="right" class="xl66">567</td> <td align="right" class="xl66">9260</td> </tr> <tr> <td align="right" class="xl66" height="18">16</td> <td align="right" class="xl66">76</td> <td align="right" class="xl66">9271</td> </tr> <tr> <td align="right" class="xl66" height="18">17</td> <td align="right" class="xl66">34</td> <td align="right" class="xl66">8851</td> </tr> <tr> <td align="right" class="xl66" height="18">18</td> <td align="right" class="xl66">97</td> <td align="right" class="xl66">8381</td> </tr> <tr> <td align="right" class="xl66" height="18">19</td> <td align="right" class="xl66">45</td> <td align="right" class="xl66">7529</td> </tr> <tr> <td align="right" class="xl66" height="18">20</td> <td align="right" class="xl66">34</td> <td align="right" class="xl66">3029</td> </tr> <tr> <td align="right" class="xl66" height="18">21</td> <td align="right" class="xl66">65</td> <td align="right" class="xl66">2527</td> </tr> <tr> <td align="right" class="xl66" height="18">22</td> <td align="right" class="xl66">765</td> <td align="right" class="xl66">2727</td> </tr> <tr> <td align="right" class="xl66" height="18">23</td> <td align="right" class="xl66">345</td> <td align="right" class="xl66">3016</td> </tr> <tr> <td align="right" class="xl66" height="18">24</td> <td align="right" class="xl66">567</td> <td align="right" class="xl66">3507</td> </tr> <tr> <td align="right" class="xl66" height="18">25</td> <td align="right" class="xl66">67</td> <td align="right" class="xl66">3229</td> </tr> <tr> <td align="right" class="xl66" height="18">26</td> <td align="right" class="xl66">34</td> <td align="right" class="xl66">2696</td> </tr> <tr> <td align="right" class="xl66" height="18">27</td> <td align="right" class="xl66">46</td> <td align="right" class="xl66">2175</td> </tr> </p></body>