Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variable problem

Hi,

how can i add a variable like "month(today())" to month in below set analysis. thanks

Sum({<year={2013},month={May},day={2}>}TRA_QTY)

30 Replies
its_anandrjs

Try like

Let currentMonth = Num( month(today()) ); //If Month field has numeric values then put Num in the expression other wise you can use same currentMonth = month(today())



Sum({<year={2013},month={' $ (currentMonth ) '},day={2}>}TRA_QTY)


tresesco
MVP
MVP

$(=Month(Today())-1 ) -> would only work if the month field contain numeric values.. Otherwise, try with addmonths(), like Sum({<year={2013},month={' $ (=Month(AddMonths(Today(),-1 ))) '},day={2}>}TRA_QTY)

Not applicable
Author

hi Ashfaq,

month should return like May not '5' and also single quotations mustn't be there.{ }.  How can i do that?

Not applicable
Author

Hi tresesco,

it s not working when there are single quotations inside of the brackets. is there any method without single quotations?

its_anandrjs

Put Num in the expression

In your Load statement add new field Num(Month) as NumMonth and use it in the expression but if it is in num then try

Sum({<year={2013},month={' $ (=Num(Month(Today())) ) '},day={2}>}TRA_QTY)

MK_QSL
MVP
MVP

Sum({<year={2013},month={'$(=SubField('$(MonthNames)', ';',Month(Today())-1))'},day={2}>}TRA_QTY)

tresesco
MVP
MVP

If your month field values like- Jan, Feb, ... It should work with single quotes/double quotes. You could post a sample qvw so that we can find the actual issue.

Not applicable
Author

Sum({<year={2013},month={ '$ (=Month(AddMonths(Today(),-1 )))' }, day={2}>}TRA_QTY)

i tried like this. but it returns value 0. but when i wrote it like this

Sum({<year={2013},month={May}, day={2}>}TRA_QTY)

it s returning values correctly. what is wrong here?

tresesco
MVP
MVP

If you put single quotes directly like: =Sum({<year={2013},month={'May'}, day={2}>}TRA_QTY)       Do you get the same value?

MK_QSL
MVP
MVP

Check my reply