Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Is there a way to write a comparison between a variable and a string in an IF-condition without single quotes ' ' ?
E.g. IF('$(vCondition)' = 'A', Field1, Field2)
Some background of why I need this. I have been trying to implement the second solution written in this article. I have a graph that should show a certain measure from a list of calculation-intensive measures based on a condition. As we know, if you place multiple measures within an IF-condition, it will first calculate all the measures, and then provide the result, which makes the app slower and less repsonsive.
Therefore, from this article, I try to build this part:
As you can see, for this we need our measures to be between single quotes.
In my case, I have something like this:
=if(vSelectMeasure=1,
'sum(IF('$(vCondition)' = 'A', Field1, Field2))',
'count(IF('$(vCondition)' = 'A', Field1, Field2))')
In this formula, we have single quotes to show which measure to use (outer-quotes), and within each measure, other single quotes to compare the condition with a string. These latter single quotes will make this fail as Qlik will think it represents the end of the first outer-quotes.
I have already tried multiple solutions not to have single quotes inside this formula, without success:
Do you have an idea of what else I could try to solve this?
Hi,
Maybe this will work:
=if(vSelectMeasure=1,
'sum(IF(' & chr(39) & '$(vCondition)' & chr(39) & ' = ' & chr(39) & 'A' & chr(39) & ', Field1, Field2))',
'count(IF(' & chr(39) & '$(vCondition)' & chr(39) & ' = ' & chr(39) & 'A' & chr(39) & ', Field1, Field2))')
Hi, thanks for your suggestion, but that didn't work.
The single quotes ' ' are still being interpreted as the end of the outer-quotes in this formula.
What is the content of vCondition variable?
The vCondition variable contains a string value (A, B, C, ...) that is being modified by the extension 'Variable input'. Therefore, it contains no calculations.