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: 
khanashique
Creator II
Creator II

set analysis with isnull function

Hi,

I am struggling  with the expression below, individual expression works fine, but when i join them with isnull function is does not return any result...

if(isnull(Year) and isnull(Month), 
Sum({<Line = {'Printing'},Year = {"$(=Year(today()))"},Date ={"=Month(today())=Month(Date)"}>}Planned_Qty)
,Sum({<Line = {'Printing'},Year = {"$(=getfieldselections(Year))"},Month = {"$(=getfieldselections(Month))"}>}Planned_Qty))

Need your kind expertise...

Thanks.

Labels (4)
1 Solution

Accepted Solutions
sunny_talwar

Yes that is because your condition is evaluated on row by row basis. For example....

2019-02-26 has a year of 2019.... IsNull(2019)? No, has a month of 02... IsNull(02), No.... so the expression used = Sum({$<Line = {'Printing'}>} Planned_Qty)

I think you need this condition

=If(GetSelectedCount(Year) = 0 or GetSelectedCount(Month) = 0.....)

or this

=If(GetSelectedCount(Year) = 0 and GetSelectedCount(Month) = 0.....)

 

Num(If(GetSelectedCount(Year) = 0 or GetSelectedCount(Month) = 0,
Sum({$<Line = {'Printing'}, Year = {"$(=Year(Today()))"}, Date = {"=Month(Today()) = Month(Date)"}>} Planned_Qty),
Sum({$<Line = {'Printing'}>} Planned_Qty)
), '#,##0')

View solution in original post

27 Replies
anushree1
Specialist II
Specialist II

Please check whether the "IF" condition is being satisfied by taking the if condition alone on a Text box , there could be chances of either of the field not being NULL or maybe its not null but space so you could also try using isnull(trim(<<fieldname>>)) in your "IF " condition.

Seyko
Partner - Creator
Partner - Creator

Hello,

Replace IsNull by a Len ( IF( Len(Year)=0 and Len (Month)=0 ....)) and see if it works.

cordially.

Excuse my english, i'm french!
sunny_talwar

Why don't you try this?

If(IsNull(Year) and IsNull(Month), 
Sum({<Line = {'Printing'}, Year = {"$(=Year(Today()))"}, Date = {"=Month(Today()) = Month(Date)"}>} Planned_Qty),
Sum({<Line = {'Printing'}>} Planned_Qty)
)
khanashique
Creator II
Creator II
Author

Thanks Sunny for your reply,

The expression you gave i have tried earlier, it does not return the result for first part of expression it returns only second part of the expression and i.e. whole data.

 

thanks once again.

 

khanashique
Creator II
Creator II
Author

hi thanks,

i have applied len (if, it returns zero as value...

 

regards.

sunny_talwar

I guess I am not sure the context of the use of your expression. From what I understood, you want to show the second expression when Year and Month are not selected. Is this not true?

khanashique
Creator II
Creator II
Author

Hi,

I wanted to show the data for first expression (for current month), when year and month is null.

Thanks...

sunny_talwar

and you have used year and month as dimension?

sunny_talwar

Also, if year and month are null... then what does this even mean?

um({<Line = {'Printing'}, Year = {"$(=Year(Today()))"}, Date = {"=Month(Today()) = Month(Date)"}>} Planned_Qty)

Year and Month are Null... why do you expect to see Year = Year(Today()) when it is null? I think you would need to provide a sample to show what you have and provide information of what you are hoping to get