Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Katerina13
Contributor II
Contributor II

Disable where clause

Hi all

My table is created as:

LOAD
"Year",
"Month",
"id",
,"quantity"
FROM [lib://Folder For QS_DATA_RU/data.QVD]
(qvd)
where Match([Year],$(vYear)) and Match([Month],$(vMonth)) and Match([id],$(v_id))
;

(vYear),(vMonth),(v_id) are variables that user enters in variable input in Sheet

It works correctly if all fields are filled in, but I face  with a problem when one of fields is empty.

If it is empty, it means table must include all (*) values by field but it doesn't filter with clause where.

 

Any ideas?

Thank you 

Labels (4)
2 Replies
anat
Master
Master

can u try something like...

if(len($vyear)<0 or len($vmonth)<0 then 

LOAD 
"Year",
"Month",
"id",
,"quantity"
FROM [lib://Folder For QS_DATA_RU/data.QVD]
(qvd);

else

LOAD 
"Year",
"Month",
"id",
,"quantity"
FROM [lib://Folder For QS_DATA_RU/data.QVD]
(qvd)
where Match([Year],$(vYear)) and Match([Month],$(vMonth)) and Match([id],$(v_id))
;

marcus_sommer

Instead of using multiple conditionally controlled load-statements you may also use queries within the where-clause, like:

where wildmatch([Year],$(vYear), '*') and ....;

Depending on if the values are numbers or strings and if the users could apply single-values or multiple ones and which char might be used as the delimiter and/or if they could enter any invalid stuff you may need some more and advanced logic to catch each possible scenario.

I don't know which variable-features are currently supported in Sense but in View you could restrict the possible values only to valid ones, for example by providing pre-calculated values from which the user choose per scroll or per drop-down. Often is this pre-defining much easier as handling all possible cases afterwards.

- Marcus