Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
muhammadraza
Partner - Creator
Partner - Creator

Compare one column each cell value with next column accumulated values - coverage ratio

Hello Guys,

I am stuck with some requirement, the image below explains the concept, PFA are the qvw and excel file. I want to achieve the same thing into Qlikview table.

coverage ratio.png

Best Regards,

Muhammad Raza

1 Solution

Accepted Solutions
Gysbert_Wassenaar

It's all done in the script:

T1:

LOAD Date(date) as date,

    [closing stock],

    forcast

FROM [comm151561.xlsx] (ooxml, embedded labels, table is Sheet2);

join

LOAD date as date_x, forcast as forcast_x

Resident T1;

T2:

LOAD *, if(stock_run >= 0,1, if(previous(stock_run) > 0, previous(stock_run)/forcast_x , 0)) as coverage;

LOAD *, rangesum([closing stock],-forcast_run) as stock_run;

LOAD *, if(date = peek(date), rangesum(forcast_x,peek(forcast_run)),forcast_x) as forcast_run

Resident T1

where date_x > date

order by date, date_x;

drop table T1;

T3:

LOAD date, [closing stock], forcast, sum(coverage) as coverage_ratio

Resident T2

group by date,[closing stock], forcast;

drop table T2;


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar

See attached qvw. Maybe that helps.


talk is cheap, supply exceeds demand
robert_mika
Master III
Master III

Could you share your Expression please?

I'm on PE.

Gysbert_Wassenaar

It's all done in the script:

T1:

LOAD Date(date) as date,

    [closing stock],

    forcast

FROM [comm151561.xlsx] (ooxml, embedded labels, table is Sheet2);

join

LOAD date as date_x, forcast as forcast_x

Resident T1;

T2:

LOAD *, if(stock_run >= 0,1, if(previous(stock_run) > 0, previous(stock_run)/forcast_x , 0)) as coverage;

LOAD *, rangesum([closing stock],-forcast_run) as stock_run;

LOAD *, if(date = peek(date), rangesum(forcast_x,peek(forcast_run)),forcast_x) as forcast_run

Resident T1

where date_x > date

order by date, date_x;

drop table T1;

T3:

LOAD date, [closing stock], forcast, sum(coverage) as coverage_ratio

Resident T2

group by date,[closing stock], forcast;

drop table T2;


talk is cheap, supply exceeds demand