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

Calculate expression if a field in the database is null

Hello,

I am loading a table from a database.

I have 3 fields, product, sales and sales estimated.

i would like an expression of the sales estimated that on a row if sales is null then sum sales estimated if is not null then don´t do anything.

thank you

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can create a flag in script like below.

Load Product,Sales,SalesEstimated,If(Isnull(Sales),1,0) as NullFlag From xyz;

Now in chart expression you can write.

Sum({<NullFlag = {"0"}>}SalesEstimated)

So this expression will consider only records which have value.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jayanttibhe
Creator III
Creator III

OR even dont need set analysis expression :  

Simply Do : Sum(NullFlag*SalesEstimated)  

Not applicable
Author

Hey,

You can handle it in script and do not worry in expression:

Load

Product,

Sales,

IF(ISNULL(Sales),[sales estimated], 0) as [sales estimated]

;

This will maintain value for sales estimated, only when Sales is null

BR,

Kuba