Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Chanty4u
MVP
MVP

RE:Pass to Variable

Hi all,

i want to pass the  field into a variable

below is my code

let vVar=  If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0);   /// this one

sample:

LOAD

    Product,

    "Year",

    "Month",

    "OrderDate",

    If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0) as CurrentMonth,     

    Sales

FROM [lib://Data/sample.xlsx]

(ooxml, embedded labels, table is Sheet1);

same i passed to variable but its not working   any other way to achieve this?

i want to compare if   data is available for current month display 1 orelse 0

thanks

Chanty

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

SET vVar=  If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0);   /// this one

sample:

LOAD

    Product,

    "Year",

    "Month",

    "OrderDate",

    $(vVar) as CurrentMonth,    

    Sales

FROM [lib://Data/sample.xlsx]

(ooxml, embedded labels, table is Sheet1);

View solution in original post

12 Replies
Clever_Anjos
Employee
Employee

SET vVar=  If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0);   /// this one

sample:

LOAD

    Product,

    "Year",

    "Month",

    "OrderDate",

    $(vVar) as CurrentMonth,    

    Sales

FROM [lib://Data/sample.xlsx]

(ooxml, embedded labels, table is Sheet1);

Chanty4u
MVP
MVP
Author

thanks clever

the script which i am using giving me correct but the variable is not working

but the variable result am getting null as a field it is giving me correct.

but i want the variable to use in Nprinting

Anil_Babu_Samineni

Seems working with SET rather LET

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Clever_Anjos
Employee
Employee

would you mind testing my solution and giving feedback?

Anil_Babu_Samineni

Seems working in field too

LET vVar=  If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0);

LOAD *,If(MonthStart(OrderDate)= MonthStart(Today(1)),1,0) as CurrentMonth Inline [

Product, Year, Month, OrderDate, Sales

A, 2017, 1, 12/1/2017, 10

B, 2016, 5, 12/10/2016, 20

C, 2015, 10, 10/10/2015, 30

];

LOAD * Inline [

FieldName

'$(vVar)'

];

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Chanty4u
MVP
MVP
Author

your way it works but that i dont need clever 

Chanty4u
MVP
MVP
Author

yes anil its working  but  same variable am giving as a condition in npritning it is not working

Anil_Babu_Samineni

I don't even what is N-Printing. May be i am going to kick that.. Not sure how to call in N-Printing.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Chanty4u
MVP
MVP
Author

there will be one option like condition there we can pass qlik variable

so now am passing above variable  like when my report having latest month data the report should send to customer  or else it should not send 

this is my requirement.    now the variable is working but when i test in nprinting the report is not generating even though current month data is there .