Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mp802377
Creator II
Creator II

If(Only creating expression

Hello,

I have this if(only expression that was used to color code if the droute was the same or different.

If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE), RGB(0,134,182), RGB(231,104,25))

They wanted to be able to separate out (toggle back and forth between 'same' and 'different'. So I created this:

=If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),'Different','Same') as an expression.

Problem is the null values for the other expressions are showing because every cell is filled out same or different. I tried to create a dimension using this

=Aggr(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),'Different')

but I get an error back. It comes back as // Error in calculated dimension

I was going to do one for 'Same' then create it conditionally based on what the radio button selected.

Thank you,

Martha

1 Solution

Accepted Solutions
mp802377
Creator II
Creator II
Author

I figured out the answer. I apologize it took so long to post.

pick(match(GetFieldSelections(_Route),'All','Same','Different')

,(Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE))

,If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),0, (Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE)))

,If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE), (Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE)),0)

)

View solution in original post

8 Replies
sunny_talwar

May be use an if statement from an expression which works

If(ExpressionLabelforExpression1 <> 0,

If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),'Different','Same'))

or this

If(Len(Trim(ExpressionLabelforExpression1)) > 0, If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),'Different','Same'))

pradosh_thakur
Master II
Master II

may be this

if(len(trim(label_which has_null)>0 ,if(expression_name_you_wrote='Diffrent',RGB(0,134,182), RGB(231,104,25)) )


check spelling errors


regards

Pradosh

Learning never stops.
sunny_talwar

I don't think color expression needs to change pradosh_thakur‌. Color expression only display colors for the rows which are displayed.

pradosh_thakur
Master II
Master II

What i thought is if the null values are showing up then len(trim()) will eliminate that and wot show the color and if same then first color and if different then other?

is it wrong? then i shall delete so others shall not be misinformed.

regards

Pradosh

Learning never stops.
sunny_talwar

It is not wrong... what I am saying is that for color expression you can only use this

if(expression_name_you_wrote='Diffrent',RGB(0,134,182), RGB(231,104,25))

and not really need to use this condition -> if(len(trim(label_which has_null)>0... this is because if your expression doesn't show anything where len of label_which has_null = 0, then your color won't really show that either... so in order to get rid of the extra rows, I would use that in the expression, not in the color.


Does that make sense?

mp802377
Creator II
Creator II
Author

The second works as an expression, but my goal is to use as a dimension. My thought was then I can click "Suppress When Value is Null'.

I created a listbox and when the user selects 'Different', I  only want the 'Different' bars to show up. Same with 'Same'.

I already have expressions that are using the conditional box. And I already have a toggle button utilizing the Layout tab under conditional, so I can't use that.

Right now, when I click on Different, the other values in the other expression are showing. Is there a way to say if expression label B is null then do not show this bar?

sunny_talwar

Would you be able to share a sample to help you better here?

mp802377
Creator II
Creator II
Author

I figured out the answer. I apologize it took so long to post.

pick(match(GetFieldSelections(_Route),'All','Same','Different')

,(Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE))

,If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE),0, (Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE)))

,If(Only({$<SITE={$(=bSite)}>} DROUTE) & Only({$<SITE={$(=bSite)}>} RROUTE) <> Only({$<SITE={$(=cSite)}>} DROUTE) & Only({$<SITE={$(=cSite)}>} RROUTE), (Min({$<SITE={$(=bSite)}>} FARE) - Min({$<SITE={$(=cSite)}>} FARE)),0)

)