Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
So I have two conditional flag s
If ForeignFlag =1 show foreign values ... if there are no foreign values then..
If StateFlag = 0 show state values
How do I incorporate this into the expression with else statement ?
if($(vFilter)=1 and ForeignFlag=1 , EntityNumber &'-'& EntityName ,
if($(vFilter)=4 and EntityTypeFlag=1, EntityNumber &'-'& EnterpriseName,))
For this, rather than an if you can just use "set analysis" to get what you whant this can work like an if or where(from SQL)
Hi,
If, then, else is totally possible, but it differs a bit depending on where you are doing it.
Are these fields in a table you are loading? If so the syntax is a bit like this:
LOAD
if(ForeignFlag = 1, [Foreign Values], if(StateFlag=0, [State Values], 'Neither Foreign or State')) as [Field Name],
If you are doing it in a chart expression it is very similar, except you would not have the "as [Field Name],". You would also typically have an aggregation, such as a Sum, to give you totals:
sum(if(ForeignFlag = 1, [Foreign Values], if(StateFlag=0, [State Values], 0)))
The load script also has VB style if then else blocks:
if ForeignFlag = 1 then
LOAD
ForeignValues...
else
if StateFlag = 0 then
LOAD
StateValues...
end if
end if
The code you posted looks fine, but to have a null value returned if neither expression is true you either need to lose that last comma, or have ", null()". Having the comma without a value after may cause it to break.
Hope that helps.
Steve
If I may add to an issue that has been expertly handled already, in QlikView script there are two IF constructs:
As a result, you can only mingle IF functions in column expressions in a LOAD statement. You cannot use IF THEN ELSE inside a LOAD statement. The net result on the other hand is identical: conditional execution/evaluation.