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: 
max_potass
Creator
Creator

an If clause with weird behavior

Note: I found a way, that I do not have to use an If clause there, so I do not need an answer anymore, but I am still interested, why this did not work.

Hello everyone,

I currently am realy confused with an if clause... I try the following:

If(Not x=y,a,b)

If x=y I actually get b. But when x is not y I do not get a.

How is this possible?

In actuallity x is a max value of a date, y is a variable (also date). a is another expression in the same chart an b is a bit complicated but actually works. It is not nice to look at but here you go:

If(Not Max({<MMM.YY = ,year = ,Type={'Ist'}>}MMM.YY)=PMM_Date_auto,

[AE Ist],

SUM({<MMM.YY = ,year = >}If(MMM.YY=MonthStart(Today(0)),AE.Netto*UKURS))

/NetWorkDays(MonthStart(Today(0)),MAX({<MMM.YY = ,year = >}True_Date),$(vPublicHolidays))

*NetWorkDays(MonthStart(Today(0)),MonthEnd(Today(0)),$(vPublicHolidays))

+SUM({<MMM.YY = ,year = >}If(MMM.YY<MonthStart(Today(0)) And MMM.YY>=YearStart(Today(0)),AE.Netto*UKURS)))

Has anyone an idea what the problem could be?

10 Replies
sunny_talwar

In my simple test, it seems to be working

Capture.PNG

Peter_Cammaert
Partner - Champion III
Partner - Champion III

One reason could be that you cannot compare anything to a NULL value.

sunny_talwar

Why don't you just do this If(x=y, 'b', 'a')

If(Max({<MMM.YY, year, Type = {'Ist'}>} MMM.YY) = PMM_Date_auto,

Sum({<MMM.YY, year>} If(MMM.YY = MonthStart(Today(0)), AE.Netto*UKURS))

/NetWorkDays(MonthStart(Today(0)),MAX({<MMM.YY = ,year = >}True_Date),$(vPublicHolidays))

*NetWorkDays(MonthStart(Today(0)),MonthEnd(Today(0)),$(vPublicHolidays))

+SUM({<MMM.YY = ,year = >}If(MMM.YY<MonthStart(Today(0)) And MMM.YY>=YearStart(Today(0)),AE.Netto*UKURS)),

[AE Ist])

max_potass
Creator
Creator
Author

I have to change that in several expressions and with the not it actually is faster to paste. Thanks for the fast response.

marcus_sommer

I think the reason is that there is no aggregation by [AE Ist] and if there are more than value available it will return NULL. Therefore try if min/max/avg([AE Ist]) change it (and return the right results).

- Marcus

max_potass
Creator
Creator
Author

So if an error occurs, it breaks the if. I see.

But it actually cannot be a null value, otherwise the whole expression cannot work.

max_potass
Creator
Creator
Author

There is only one Vaule in [AE Ist]. If i just use it as expression it works.

max_potass
Creator
Creator
Author

I know... I tested it, too.

max_potass
Creator
Creator
Author

I found a way, that I do not have to use an If clause there, so I do not need an answer anymore, but I am still interested, why this did not work.