Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Current month not working

Hi experts

We are working with stock measures, non-cumulative. I need to see only the stock of the current month. The following formula doesn't work. It shows the YTD value, in our case January and February. I only need to see the stocks for February. This formula seens to be ineffective:

Sum({$<MonthNum={'$(=(MonthNum)today())'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

Any ideas?

Thanks

Tom

1 Solution

Accepted Solutions
micheledenardi
Specialist II
Specialist II

This should work,

be sure about the name of MonthNum or %MonthNum:

Sum({$<MonthNum={'$(=num(month(today(1))))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

10 Replies
NitinK7
Specialist
Specialist

Hi, 

Try below expression

Sum({$<MonthNum={'$(=Num(Month(today())))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

micheledenardi
Specialist II
Specialist II

I believe MonthNum() is not valid function:

Try this:

Sum({$<MonthNum={'$(=num(month(today(1))))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
TomBond77
Specialist
Specialist
Author

Thanks guys

Both proposals also don't work. Any more ideas?

Regards

Tom

micheledenardi
Specialist II
Specialist II

Which is the format of MonthNum? 2 or 02 ? Or something else?

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
micheledenardi
Specialist II
Specialist II

if is two digits 02 you can use this:

 

Sum({$<MonthNum={'$(=mid(today(1),4,2))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
NitinK7
Specialist
Specialist

Hi

Monthnum(Highlighted in red) is your field?? , if yes then could please paste here value of monthnum field

 

Sum({$<MonthNum={'$(=(MonthNum)today())'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

 

 

TomBond77
Specialist
Specialist
Author

TomBond77_0-1614068311780.png

 

micheledenardi
Specialist II
Specialist II

This should work,

be sure about the name of MonthNum or %MonthNum:

Sum({$<MonthNum={'$(=num(month(today(1))))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
NitinK7
Specialist
Specialist

make sure to passing % Monthnum or Monthnum 

or you can hide % sign using below set variable in script 

set HidePrefix='%';

then load your data 

and then try below expression 

Sum({$<MonthNum={'$(=Num(Month(today())))'}, [Product Unit]={'Cars','Bikes','Trucks'}>} [Total Stock])