Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
anushree1
Specialist II
Specialist II

Null appears as Zero when using inside Sum Function

HI,

I am creating YOY Sales in the Backend using PEEK function to get the Previous Year Value.

This works fine, the first entry of the Year appears as'-' in the data model for PrevYr as expected.

But, when i create a chart basis this the PrevYr ,it appears as Zero on the First Year though it is supposed to be '-' when i use it inside Sum like Sum(PrevYr) but , if use just PrevYr as the expression it results with '-' 

I would like to get '-' for the first entry as there is no previous year for it , even if i use Sum function.

Can someone please suggest how this could be done

12 Replies
marcus_sommer

I'm not sure if it's possible at least not without any ugly side-effects ... you may use:

If(Len(concat(PrevYr, ','))=0, dual('-', 0) , Sum(PrevYr ))

or

If(Len(concat(PrevYr, ','))=0, dual('-', min/max(total aggr(Sum(PrevYr ), Dim1, Dim2)) +-1) , Sum(PrevYr ))

but it will for example make trouble in totals and might be there calculated different - maybe by querying the levels with dimensionality() or ...

- Marcus

anushree1
Specialist II
Specialist II
Author

it is not working

marcus_sommer

You could not take the suggestion 1:1 because it's just a generic example to show which various measures might be useful. It needs the appropriate adjustments to your data-structure, fieldnames and a valid syntax.

- Marcus