Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nisha_rai
Creator II
Creator II

Load data based on condition

Hi,

I have a scenario for showing the data in QV based on condition

Eg:

YearMonthitemSales
20171A12
20171B14
20172A15
20172B10
20173A17

Above is my table whichis store in Qvd form,

Now i have to check the Item with respect to Year Month

If in maximum month we have both item then we have to load the full table as it is, else we have to load the previous month data from table:

Result1: Find the max date from table and then find out the item

Maxdate=1/3/2017 Item =A(only)

in that base we have to load the data till previous month

Result2:

Maxdate=1/3/2017 Item =A & B

then we have to load the full table

In the above example , we are showing data till "Feb " only because in March we have only one month.

Please help me to resolve the above scenario.

Thanks & Regards,

Nisha

1 Solution

Accepted Solutions
PunamWagh
Contributor III
Contributor III

Dear Nisha,

Please have a look.

Regards,

Punam

View solution in original post

2 Replies
PunamWagh
Contributor III
Contributor III

Dear Nisha,

Please have a look.

Regards,

Punam

Kushal_Chawda

Data:

LOAD Year,

     Month,

     floor(Year&num(Month,'00')) as MonthYear,

     item,

     Sales

FROM

[https://community.qlik.com/thread/268471]

(html, codepage is 1252, embedded labels, table is @1);

Left Join(Data)

load max(MonthYear) as MonthYear,

     1 as MaxFlag

Resident Data;

CountItem:

LOAD Count(DISTINCT item) as CountItem,

     MonthYear

Resident Data

where MaxFlag=1

Group by MonthYear;

LET vItemCount = Peek('CountItem',0,'CountItem');

LET vMaxMonth = Peek('MonthYear',0,'CountItem');

if $(vItemCount)=1 then

Final:

NoConcatenate

LOAD *

Resident Data

where MonthYear < '$(vMaxMonth)';

DROP Table Data;

ELSE

TRACE "Data is already loaded till date" ;

ENDIF

DROP Table CountItem;

Capture.JPG