Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I would like to use the following statement in my script, but it doesn't work:
"reisezeit" is a variable which can be 0 or 1.
if reisezeit = 1 then
sum(if(Reisezeit='Nein', Stunden) )as Stunden_Projekt;
elseif
reisezeit = 0
sum(Stunden) as Stunden_Projekt;
ELSE
sum(Stunden) as Stunden_Projekt;
end if
Does someone has an idea why?
Thank you for your help.
If you use other fields in your load statement, you must have a Group By Clause in your script.
LOAD
dimension1,
If ($(reisezeit) = 1,
sum(if(Reisezeit='Nein', Stunden)),
sum(Stunden)
) as Stunden_Projekt
RESIDENT Data
GROUP BY dimension1 ;
I used dmension1 as example.
Hi robert2012,
Can you change if reisezeit to if $(reisezeit) then try again.
Regards,
Sokkorn
try this:
if($(Reisezeit) = 1,sum(if($(Reisezeit)='Nein', Stunden,if($(Reisezeit) = 0,sum(Stunden))))) as Stunden_Projekt
HTTH
Sushil
Hi,
thx, but there is still a mistake as QlikView says:
Error in expression:
')' expected
But I don't see where!
You?
Hi Sokkorn,
thank you very much.
I changed the first and both, but it still doens't work.
It says: Syntax Fehler
You know why?
This should work ...
if(reisezeit=1,sum(if(Reisezeit='Nein',Stunden)),sum(Stunden)) as Stunden_Projekt;
Message was edited by: Anand K
Hi,
thank u for your help:
I added $ for the variables:
if($(reisezeit) = 1,sum(if($(reisezeit)='Nein',Stunden)),sum(Stunden)) as Stunden_Projekt
Now QlikView says:
If takes 2-3 parameters
Try this :
if ($(reisezeit) = 1,
sum(if(Reisezeit='Nein', Stunden)),
if($(reisezeit)=0,
sum(Stunden),
sum(Stunden)
)
) as Stunden_Projekt ;
If your variable takes only values 1 or 0, you can also write this :
if ($(reisezeit) = 1,
sum(if(Reisezeit='Nein', Stunden)),
sum(Stunden)
) as Stunden_Projekt;
Thank you!
But there is "Error in expression: If takes 2-3 parameters"
for both ideas.
What can I do?
Remove the '$' sign and it should work for you