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: 
Anonymous
Not applicable

How to use this function"sum({<YEAR={'2014'},Month={'APR'}>}HWB_WT/1000)+sum({<YEAR={'2014'},Month={'APR'}>}VOLUME_IN_TEUS)"

hi

  we need to check month & year, we use this function "sum({<YEAR={'2014'},Month={'APR'}>}HWB_WT/1000)+sum({<YEAR={'2014'},Month={'APR'}>}VOLUME_IN_TEUS)" but the result showing zero. kindly advice me,how to use this function.

Thanks

9 Replies
Anonymous
Not applicable
Author

Can you post example QVW. Thanks

anbu1984
Master III
Master III

Verify Month column month format matches with your value('APR')

its_anandrjs

Try with this

=(sum({<YearField={'2014'},Month={'APR'}>} HWB_WT) / 1000) +

  sum({<YearField={'2014'},Month={'APR'}>}VOLUME_IN_TEUS)

Or

=sum({<YearField={'2014'},Month={'APR'}>} (HWB_WT / 1000 ) ) +

  sum({<YearField={'2014'},Month={'APR'}>}VOLUME_IN_TEUS)

Or may be check the Month values it is APR or Apr cross check.

Anonymous
Not applicable
Author

HI

Thanks for your support. we will try same .

jagan
Luminary Alumni
Luminary Alumni

Hi,

Check this

sum({<YEAR={'2014'},Month={'Apr'}>}HWB_WT/1000)+sum({<YEAR={'2014'},Month={'Apr'}>}VOLUME_IN_TEUS)


Or

sum({<YEAR={'2014'},Month={4}>}HWB_WT/1000)+sum({<YEAR={'2014'},Month={4}>}VOLUME_IN_TEUS)


If not working, then post the sample? what is the format of month in your data model, is APR or Apr or 4.  Is YEAR and Month fields exists in your datamodel?


Regards,

Jagan.



magavi_framsteg
Partner - Creator III
Partner - Creator III

Hey.

It is *much* better to do this calculation in ONE {set} instead of two sets.

Calculation time will be significantly lower.

Like this:

sum({<YEAR={'2014'},Month={'APR'}>}HWB_WT/1000+VOLUME_IN_TEUS)

If possible, always try and make as few sets as possible.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I agree, but with one modification:

sum({<YEAR={'2014'},Month={'APR'}>} RangeSum(HWB_WT/1000, VOLUME_IN_TEUS))


... to ensure that the result is still correct if one of the values is null. If your system guarrantees that there are no nulls in either of these two fields, then the RangeSum() is not required.


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
magavi_framsteg
Partner - Creator III
Partner - Creator III

Yes.

And if we are optimizing, why not make a YearMonth field and issue ONE selection instead of two:

sum({<YEARMONTH={201404}>} RangeSum(HWB_WT/1000, VOLUME_IN_TEUS))

Also, notice that YEARMONTH is selected by its integer value rather than it's casted string equivalent.

its_anandrjs

If you got correct then close the thread as Correct or helpful for references.

Thanks & Regards