22 Replies Latest reply: Jul 26, 2017 8:20 AM by Andrea Gigliotti

# how to compare two calculated dimensions

HI

how can we use Master item (dimension) in calcuating another master item as comparing if one master item value is greater . than another master item value then 1 else 0

can we use as above

• ###### Re: how to compare two calculated dimensions

Hi,

We can't directly use master item in other expressions. Maybe we need to use full calculated dimension in other expression as well.

• ###### Re: how to compare two calculated dimensions

Hi Nagamani,

you can use the set expression to compare two calculated dimensions, but give more information or screenshot of your expected output

Beck

• ###### Re: how to compare two calculated dimensions

HI

i have created one dimension as 'createdate' where i changed date format  and also created another dimension as 'Completed date'

Now how can i use these two dimension columns

i need to do calculate cretaedate-completeddate

• ###### Re: how to compare two calculated dimensions

Can you give your example qliksense-file?

• ###### Re: how to compare two calculated dimensions

Hi Nagamani,

You can create variables and compare or else straight away, use the calculated dimension (expressions) for comparing purpose.

Ex: I have two variables varMaxDate = 7/26/2017 and varMinDate = 3/1/2017.

I used these two variables in an expression to compare i.e. if(\$(varMaxDate) > \$(varMinDate), 'Max', 'Min')

-Prashanth

• ###### Re: how to compare two calculated dimensions

hi

i have numerical values and tried your syntax. it is not throughing any error but it is brining else part even i have A value greater than B value it is not brining 0 value it is always showing 1

if(\$(A) > \$(B), '0', '1')

• ###### Re: how to compare two calculated dimensions

How come?

Is it possible to provide variable A and B expressions and values?

• ###### Re: how to compare two calculated dimensions

that is my requirement

i have created two master columns A and B. These two columns having numerical values.

Now i have to compare Column A and B values if A column value is greater than B value then 1 if not 0 value have to populate in new column.

Can you help on this

• ###### Re: how to compare two calculated dimensions

could be easy to help you if you post a sample app.

• ###### Re: how to compare two calculated dimensions

can yo assist based on sample information i provided

• ###### Re: how to compare two calculated dimensions

Your statement and expression differs to each other.

Statement: Now i have to compare Column A and B values if A column value is greater than B value then 1 if not 0 value have to populate in new column.

Expression: if(\$(A) > \$(B), '0', '1')

In above statement, you are saying if A>B then 1 but in expression, you wrote it to return "0" .

Still, I'm showing real time example:

I used below expressions to achieve the values mentioned in above image.

'varA: ' & \$(varMaxDate)

'varB: ' & \$(varMinDate)

'if(varA > varB, 0, 1) ---> Result: ' & if(\$(varMaxDate) > \$(varMinDate), 0, 1)

• ###### Re: how to compare two calculated dimensions

if(\$(varMaxDate) > \$(varMinDate), 0, 1), tried this

but it always gives 1, even if condition '0' satified it never showed up 0

• ###### Re: how to compare two calculated dimensions

try below:

if( num(\$(varMaxDate)) > num(\$(varMinDate)), 0, 1)

• ###### Re: how to compare two calculated dimensions

can you provide information as how greater than or less than operators for two values

atleast i will try to write all if conditions which i used in creating master items and try on that