Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to Calculate with Month Number

Trying to divide Sales thru the end of the last month by the number of months, but I cannot get this to work.

(Sum({$<_YTDAsOfLastMonth={1},Year={$(=Max(Year))}>}[Invoiced Order Net Revenue])) / (Num(Month(vEndOfLastMonth)))

The first half of this formula before the division sign works, but when I try to use a variable to create the month number for the last month, and divide, it doesn't work.  I'm sure I'm missing something little, so I'd appreciate any help.  Thanks.

4 Replies
Not applicable
Author

Try with this:

(Num(Month($(vEndOfLastMonth))))

Not applicable
Author

Good idea, as I thought about the $ too… I just tried (Sum({$<_YTDAsOfLastMonth={1},Year={$(=Max(Year))}>}[Invoiced Order Net Revenue])) / (Num(Month($(vEndOfLastMonth)))

And it still doesn’t work.

Thanks,

Shelley

Shelley Smith | Manager, Business Intelligence and Analytics

Spacesaver Corporation

DIRECT:: 920.563.0548 | CELL:: 608.751.4295 | TOLL:: 800.492.3434

FAX:: 920.563.0712 | WEB:: www.spacesaver.com

Not applicable
Author

Can you post a sample qvw?

stigchel
Partner - Master
Partner - Master

The function Month expects a valid Timestamp as parameter, the variable is probably text?

try

Month(Date#('$(vEndOfLastMonth)','YourDateFormat'))