Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Rudo6
Contributor II
Contributor II

Referring to already calculated field - Master items (?)

Hello.

Would you please help me someone what are the possibilities to refer to a column/field, that is the result of certain calculation , e.g. "IF" command ? The goal is to avoid re-writing the code again. I found one type of answer >> using PICK() and MATCH() combination. That of course work. But I was also told that second way is to add a calculated field to Master items. I tried it, put it into Master items and wanted to refer to it when creating a new field but Qlik couldn't recognize this Master item. 

E.g.
[my_master_item]=123&'a'

IF ([my_master_item] = 'xxx', 'OK','NOT OK') .... but my_master_item wasn't recognized. Here I expect to get result "NOT OK'

Another option is to use function Column()....but this can be a problematic as I can easily change a column's order.

Thanks a lot for help.

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

You can make reference to master measures from another measure, though you'll need to make sure you don't end up with nonsense or nested aggregations.

Alternatively, you can also use variables if you need to refer to the same calculation multiple times and would prefer to only maintain it once. Another alternative is to create the field in script and then you can just reference it as you would any other field.

In the specific example above, it's unclear why you need anything in the first place since you're just adding 'a' to the end of a string, so a basic wildmatch() would work without needing to do that. I'm assuming the example doesn't actually reflect whatever it is you're trying to do.

View solution in original post

5 Replies
Or
MVP
MVP

You can make reference to master measures from another measure, though you'll need to make sure you don't end up with nonsense or nested aggregations.

Alternatively, you can also use variables if you need to refer to the same calculation multiple times and would prefer to only maintain it once. Another alternative is to create the field in script and then you can just reference it as you would any other field.

In the specific example above, it's unclear why you need anything in the first place since you're just adding 'a' to the end of a string, so a basic wildmatch() would work without needing to do that. I'm assuming the example doesn't actually reflect whatever it is you're trying to do.

Rudo6
Contributor II
Contributor II
Author

Thanks a lot for reply.  Tomorrow, I will try your ideas in practically:-) 

Yes, above example is just testing if I can refer to already calculated item with its Label name .

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can use a Master Measure by name in an expression. You cannot use a Master Dimension in an expression.

You can refer to a chart Measure column by Column(n) or by the label of the chart column. Referring to the label addresses the problem of the column being rearranged. 

-Rob

Rudo6
Contributor II
Contributor II
Author

Thank you once again for your help. I tested it and it works. Unfortunately, as you wrote, I can refer only to Master measure and only in field that is also defined as measure.  

One more question pls. What did you mean by this statement : "Another alternative is to create the field in script and then you can just reference it as you would any other field." I mean, what do you mean by "script" ?

Have a fine rest of day.

Or
MVP
MVP

Your script is where you load data. For example,

Load Field1, Field2, Field3 & 'a' as NewField3

From Sometable;

 

You could then use NewField3 in calculations, same as any other field.